public Request<UpdateDomainNameserversRequest> marshall(
      UpdateDomainNameserversRequest updateDomainNameserversRequest) {

    if (updateDomainNameserversRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<UpdateDomainNameserversRequest> request =
        new DefaultRequest<UpdateDomainNameserversRequest>(
            updateDomainNameserversRequest, "AmazonRoute53Domains");
    request.addHeader("X-Amz-Target", "Route53Domains_v20140515.UpdateDomainNameservers");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (updateDomainNameserversRequest.getDomainName() != null) {
        jsonWriter.key("DomainName").value(updateDomainNameserversRequest.getDomainName());
      }

      if (updateDomainNameserversRequest.getFIAuthKey() != null) {
        jsonWriter.key("FIAuthKey").value(updateDomainNameserversRequest.getFIAuthKey());
      }

      com.amazonaws.internal.SdkInternalList<Nameserver> nameserversList =
          (com.amazonaws.internal.SdkInternalList<Nameserver>)
              updateDomainNameserversRequest.getNameservers();
      if (!nameserversList.isEmpty() || !nameserversList.isAutoConstruct()) {
        jsonWriter.key("Nameservers");
        jsonWriter.array();
        for (Nameserver nameserversListValue : nameserversList) {
          if (nameserversListValue != null) {

            NameserverJsonMarshaller.getInstance().marshall(nameserversListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
コード例 #2
0
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(OperationSummary operationSummary, JSONWriter jsonWriter) {
    if (operationSummary == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (operationSummary.getOperationId() != null) {
        jsonWriter.key("OperationId").value(operationSummary.getOperationId());
      }

      if (operationSummary.getStatus() != null) {
        jsonWriter.key("Status").value(operationSummary.getStatus());
      }

      if (operationSummary.getType() != null) {
        jsonWriter.key("Type").value(operationSummary.getType());
      }

      if (operationSummary.getSubmittedDate() != null) {
        jsonWriter.key("SubmittedDate").value(operationSummary.getSubmittedDate());
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<EnableDomainTransferLockRequest> marshall(
      EnableDomainTransferLockRequest enableDomainTransferLockRequest) {
    if (enableDomainTransferLockRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<EnableDomainTransferLockRequest> request =
        new DefaultRequest<EnableDomainTransferLockRequest>(
            enableDomainTransferLockRequest, "AmazonRoute53Domains");
    String target = "Route53Domains_v20140515.EnableDomainTransferLock";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (enableDomainTransferLockRequest.getDomainName() != null) {
        jsonWriter.key("DomainName").value(enableDomainTransferLockRequest.getDomainName());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }