public Request<CreateWorkspacesRequest> marshall(
      CreateWorkspacesRequest createWorkspacesRequest) {
    if (createWorkspacesRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreateWorkspacesRequest> request =
        new DefaultRequest<CreateWorkspacesRequest>(createWorkspacesRequest, "AmazonWorkspaces");
    String target = "WorkspacesService.CreateWorkspaces";
    request.addHeader("X-Amz-Target", target);

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

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

      jsonWriter.object();

      com.amazonaws.internal.ListWithAutoConstructFlag<WorkspaceRequest> workspacesList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<WorkspaceRequest>)
              (createWorkspacesRequest.getWorkspaces());
      if (workspacesList != null
          && !(workspacesList.isAutoConstruct() && workspacesList.isEmpty())) {

        jsonWriter.key("Workspaces");
        jsonWriter.array();

        for (WorkspaceRequest workspacesListValue : workspacesList) {
          if (workspacesListValue != null) {
            jsonWriter.object();
            if (workspacesListValue.getDirectoryId() != null) {
              jsonWriter.key("DirectoryId").value(workspacesListValue.getDirectoryId());
            }
            if (workspacesListValue.getUserName() != null) {
              jsonWriter.key("UserName").value(workspacesListValue.getUserName());
            }
            if (workspacesListValue.getBundleId() != null) {
              jsonWriter.key("BundleId").value(workspacesListValue.getBundleId());
            }
            jsonWriter.endObject();
          }
        }
        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;
  }
  public Request<CreateIdentityPoolRequest> marshall(
      CreateIdentityPoolRequest createIdentityPoolRequest) {
    if (createIdentityPoolRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreateIdentityPoolRequest> request =
        new DefaultRequest<CreateIdentityPoolRequest>(
            createIdentityPoolRequest, "AmazonCognitoIdentity");
    String target = "AWSCognitoIdentityService.CreateIdentityPool";
    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 (createIdentityPoolRequest.getIdentityPoolName() != null) {
        jsonWriter.key("IdentityPoolName").value(createIdentityPoolRequest.getIdentityPoolName());
      }
      if (createIdentityPoolRequest.isAllowUnauthenticatedIdentities() != null) {
        jsonWriter
            .key("AllowUnauthenticatedIdentities")
            .value(createIdentityPoolRequest.isAllowUnauthenticatedIdentities());
      }
      if (createIdentityPoolRequest.getSupportedLoginProviders() != null) {
        jsonWriter.key("SupportedLoginProviders");
        jsonWriter.object();
        for (Map.Entry<String, String> supportedLoginProvidersListValue :
            createIdentityPoolRequest.getSupportedLoginProviders().entrySet()) {
          if (supportedLoginProvidersListValue.getValue() != null) {
            jsonWriter.key(supportedLoginProvidersListValue.getKey());

            jsonWriter.value(supportedLoginProvidersListValue.getValue());
          }
        }
        jsonWriter.endObject();
      }

      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.0");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<SetIdentityPoolRolesRequest> marshall(
      SetIdentityPoolRolesRequest setIdentityPoolRolesRequest) {

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

    Request<SetIdentityPoolRolesRequest> request =
        new DefaultRequest<SetIdentityPoolRolesRequest>(
            setIdentityPoolRolesRequest, "AmazonCognitoIdentity");
    request.addHeader("X-Amz-Target", "AWSCognitoIdentityService.SetIdentityPoolRoles");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonWriter.object();

      if (setIdentityPoolRolesRequest.getIdentityPoolId() != null) {
        jsonWriter.key("IdentityPoolId").value(setIdentityPoolRolesRequest.getIdentityPoolId());
      }

      java.util.Map<String, String> rolesMap = setIdentityPoolRolesRequest.getRoles();
      if (rolesMap != null) {
        jsonWriter.key("Roles");
        jsonWriter.object();

        for (Map.Entry<String, String> rolesMapValue : rolesMap.entrySet()) {
          if (rolesMapValue.getValue() != null) {
            jsonWriter.key(rolesMapValue.getKey());

            jsonWriter.value(rolesMapValue.getValue());
          }
        }
        jsonWriter.endObject();
      }

      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;
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(DetectedProperties detectedProperties, JSONWriter jsonWriter) {
    if (detectedProperties == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (detectedProperties.getWidth() != null) {
        jsonWriter.key("Width").value(detectedProperties.getWidth());
      }

      if (detectedProperties.getHeight() != null) {
        jsonWriter.key("Height").value(detectedProperties.getHeight());
      }

      if (detectedProperties.getFrameRate() != null) {
        jsonWriter.key("FrameRate").value(detectedProperties.getFrameRate());
      }

      if (detectedProperties.getFileSize() != null) {
        jsonWriter.key("FileSize").value(detectedProperties.getFileSize());
      }

      if (detectedProperties.getDurationMillis() != null) {
        jsonWriter.key("DurationMillis").value(detectedProperties.getDurationMillis());
      }

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

    Request<ListTablesRequest> request =
        new DefaultRequest<ListTablesRequest>(listTablesRequest, "AmazonDynamoDBv2");
    String target = "DynamoDB_20120810.ListTables";
    request.addHeader("X-Amz-Target", target);
    request.addHeader("Content-Type", "application/x-amz-json-1.0");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "";

    uriResourcePath = uriResourcePath.replaceAll("//", "/");

    if (uriResourcePath.contains("?")) {
      String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1);
      uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?"));

      for (String s : queryString.split("[;&]")) {
        String[] nameValuePair = s.split("=");
        if (nameValuePair.length == 2) {
          request.addParameter(nameValuePair[0], nameValuePair[1]);
        } else {
          request.addParameter(s, null);
        }
      }
    }

    request.setResourcePath(uriResourcePath);

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

      jsonWriter.object();

      if (listTablesRequest.getExclusiveStartTableName() != null) {
        jsonWriter
            .key("ExclusiveStartTableName")
            .value(listTablesRequest.getExclusiveStartTableName());
      }
      if (listTablesRequest.getLimit() != null) {
        jsonWriter.key("Limit").value(listTablesRequest.getLimit());
      }

      jsonWriter.endObject();

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

    return request;
  }
  /** 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);
    }
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(EC2TagFilter eC2TagFilter, JSONWriter jsonWriter) {
    if (eC2TagFilter == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (eC2TagFilter.getKey() != null) {
        jsonWriter.key("Key").value(eC2TagFilter.getKey());
      }

      if (eC2TagFilter.getValue() != null) {
        jsonWriter.key("Value").value(eC2TagFilter.getValue());
      }

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

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(Artifact artifact, JSONWriter jsonWriter) {
    if (artifact == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (artifact.getName() != null) {
        jsonWriter.key("name").value(artifact.getName());
      }

      if (artifact.getRevision() != null) {
        jsonWriter.key("revision").value(artifact.getRevision());
      }

      if (artifact.getLocation() != null) {
        jsonWriter.key("location");
        ArtifactLocationJsonMarshaller.getInstance().marshall(artifact.getLocation(), jsonWriter);
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(Telemetry telemetry, JSONWriter jsonWriter) {
    if (telemetry == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (telemetry.getStatus() != null) {
        jsonWriter.key("status").value(telemetry.getStatus());
      }

      java.util.List<MessageTypeTelemetry> messageTypeTelemetriesList =
          telemetry.getMessageTypeTelemetries();
      if (messageTypeTelemetriesList != null) {
        jsonWriter.key("messageTypeTelemetries");
        jsonWriter.array();
        for (MessageTypeTelemetry messageTypeTelemetriesListValue : messageTypeTelemetriesList) {
          if (messageTypeTelemetriesListValue != null) {

            MessageTypeTelemetryJsonMarshaller.getInstance()
                .marshall(messageTypeTelemetriesListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
Exemplo n.º 10
0
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(Service service, JSONWriter jsonWriter) {
    if (service == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (service.getCode() != null) {
        jsonWriter.key("code").value(service.getCode());
      }

      if (service.getName() != null) {
        jsonWriter.key("name").value(service.getName());
      }

      com.amazonaws.internal.SdkInternalList<Category> categoriesList =
          (com.amazonaws.internal.SdkInternalList<Category>) service.getCategories();
      if (!categoriesList.isEmpty() || !categoriesList.isAutoConstruct()) {
        jsonWriter.key("categories");
        jsonWriter.array();
        for (Category categoriesListValue : categoriesList) {
          if (categoriesListValue != null) {

            CategoryJsonMarshaller.getInstance().marshall(categoriesListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(Notifications notifications, JSONWriter jsonWriter) {
    if (notifications == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (notifications.getProgressing() != null) {
        jsonWriter.key("Progressing").value(notifications.getProgressing());
      }

      if (notifications.getCompleted() != null) {
        jsonWriter.key("Completed").value(notifications.getCompleted());
      }

      if (notifications.getWarning() != null) {
        jsonWriter.key("Warning").value(notifications.getWarning());
      }

      if (notifications.getError() != null) {
        jsonWriter.key("Error").value(notifications.getError());
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(TemporaryCredential temporaryCredential, JSONWriter jsonWriter) {
    if (temporaryCredential == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (temporaryCredential.getUsername() != null) {
        jsonWriter.key("Username").value(temporaryCredential.getUsername());
      }

      if (temporaryCredential.getPassword() != null) {
        jsonWriter.key("Password").value(temporaryCredential.getPassword());
      }

      if (temporaryCredential.getValidForInMinutes() != null) {
        jsonWriter.key("ValidForInMinutes").value(temporaryCredential.getValidForInMinutes());
      }

      if (temporaryCredential.getInstanceId() != null) {
        jsonWriter.key("InstanceId").value(temporaryCredential.getInstanceId());
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(ActionRevision actionRevision, JSONWriter jsonWriter) {
    if (actionRevision == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (actionRevision.getRevisionId() != null) {
        jsonWriter.key("revisionId").value(actionRevision.getRevisionId());
      }

      if (actionRevision.getRevisionChangeId() != null) {
        jsonWriter.key("revisionChangeId").value(actionRevision.getRevisionChangeId());
      }

      if (actionRevision.getCreated() != null) {
        jsonWriter.key("created").value(actionRevision.getCreated());
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  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;
  }
  public Request<CreateSnapshotRequest> marshall(CreateSnapshotRequest createSnapshotRequest) {
    if (createSnapshotRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreateSnapshotRequest> request =
        new DefaultRequest<CreateSnapshotRequest>(createSnapshotRequest, "AWSStorageGateway");
    String target = "StorageGateway_20130630.CreateSnapshot";
    request.addHeader("X-Amz-Target", target);
    request.addHeader("Content-Type", "application/x-amz-json-1.1");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "";

    uriResourcePath = uriResourcePath.replaceAll("//", "/");

    if (uriResourcePath.contains("?")) {
      String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1);
      uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?"));

      for (String s : queryString.split("[;&]")) {
        String[] nameValuePair = s.split("=");
        if (nameValuePair.length == 2) {
          request.addParameter(nameValuePair[0], nameValuePair[1]);
        } else {
          request.addParameter(s, null);
        }
      }
    }

    request.setResourcePath(uriResourcePath);

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

      jsonWriter.object();

      if (createSnapshotRequest.getVolumeARN() != null) {
        jsonWriter.key("VolumeARN").value(createSnapshotRequest.getVolumeARN());
      }
      if (createSnapshotRequest.getSnapshotDescription() != null) {
        jsonWriter.key("SnapshotDescription").value(createSnapshotRequest.getSnapshotDescription());
      }

      jsonWriter.endObject();

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

    return request;
  }
  public Request<CreateHsmRequest> marshall(CreateHsmRequest createHsmRequest) {
    if (createHsmRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreateHsmRequest> request =
        new DefaultRequest<CreateHsmRequest>(createHsmRequest, "AWSCloudHSM");
    String target = "CloudHsmFrontendService.CreateHsm";
    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 (createHsmRequest.getSubnetId() != null) {
        jsonWriter.key("SubnetId").value(createHsmRequest.getSubnetId());
      }
      if (createHsmRequest.getSshKey() != null) {
        jsonWriter.key("SshKey").value(createHsmRequest.getSshKey());
      }
      if (createHsmRequest.getEniIp() != null) {
        jsonWriter.key("EniIp").value(createHsmRequest.getEniIp());
      }
      if (createHsmRequest.getIamRoleArn() != null) {
        jsonWriter.key("IamRoleArn").value(createHsmRequest.getIamRoleArn());
      }
      if (createHsmRequest.getExternalId() != null) {
        jsonWriter.key("ExternalId").value(createHsmRequest.getExternalId());
      }
      if (createHsmRequest.getSubscriptionType() != null) {
        jsonWriter.key("SubscriptionType").value(createHsmRequest.getSubscriptionType());
      }
      if (createHsmRequest.getClientToken() != null) {
        jsonWriter.key("ClientToken").value(createHsmRequest.getClientToken());
      }
      if (createHsmRequest.getSyslogIp() != null) {
        jsonWriter.key("SyslogIp").value(createHsmRequest.getSyslogIp());
      }

      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;
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(ItemCollectionMetrics itemCollectionMetrics, JSONWriter jsonWriter) {
    if (itemCollectionMetrics == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      java.util.Map<String, AttributeValue> itemCollectionKeyMap =
          itemCollectionMetrics.getItemCollectionKey();
      if (itemCollectionKeyMap != null) {
        jsonWriter.key("ItemCollectionKey");
        jsonWriter.object();

        for (Map.Entry<String, AttributeValue> itemCollectionKeyMapValue :
            itemCollectionKeyMap.entrySet()) {
          if (itemCollectionKeyMapValue.getValue() != null) {
            jsonWriter.key(itemCollectionKeyMapValue.getKey());

            AttributeValueJsonMarshaller.getInstance()
                .marshall(itemCollectionKeyMapValue.getValue(), jsonWriter);
          }
        }
        jsonWriter.endObject();
      }

      java.util.List<Double> sizeEstimateRangeGBList =
          itemCollectionMetrics.getSizeEstimateRangeGB();
      if (sizeEstimateRangeGBList != null) {
        jsonWriter.key("SizeEstimateRangeGB");
        jsonWriter.array();
        for (Double sizeEstimateRangeGBListValue : sizeEstimateRangeGBList) {
          if (sizeEstimateRangeGBListValue != null) {
            jsonWriter.value(sizeEstimateRangeGBListValue);
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(TrustedAdvisorCheckResult trustedAdvisorCheckResult, JSONWriter jsonWriter) {
    if (trustedAdvisorCheckResult == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (trustedAdvisorCheckResult.getCheckId() != null) {
        jsonWriter.key("checkId").value(trustedAdvisorCheckResult.getCheckId());
      }

      if (trustedAdvisorCheckResult.getTimestamp() != null) {
        jsonWriter.key("timestamp").value(trustedAdvisorCheckResult.getTimestamp());
      }

      if (trustedAdvisorCheckResult.getStatus() != null) {
        jsonWriter.key("status").value(trustedAdvisorCheckResult.getStatus());
      }

      if (trustedAdvisorCheckResult.getResourcesSummary() != null) {
        jsonWriter.key("resourcesSummary");
        TrustedAdvisorResourcesSummaryJsonMarshaller.getInstance()
            .marshall(trustedAdvisorCheckResult.getResourcesSummary(), jsonWriter);
      }

      if (trustedAdvisorCheckResult.getCategorySpecificSummary() != null) {
        jsonWriter.key("categorySpecificSummary");
        TrustedAdvisorCategorySpecificSummaryJsonMarshaller.getInstance()
            .marshall(trustedAdvisorCheckResult.getCategorySpecificSummary(), jsonWriter);
      }

      com.amazonaws.internal.SdkInternalList<TrustedAdvisorResourceDetail> flaggedResourcesList =
          (com.amazonaws.internal.SdkInternalList<TrustedAdvisorResourceDetail>)
              trustedAdvisorCheckResult.getFlaggedResources();
      if (!flaggedResourcesList.isEmpty() || !flaggedResourcesList.isAutoConstruct()) {
        jsonWriter.key("flaggedResources");
        jsonWriter.array();
        for (TrustedAdvisorResourceDetail flaggedResourcesListValue : flaggedResourcesList) {
          if (flaggedResourcesListValue != null) {

            TrustedAdvisorResourceDetailJsonMarshaller.getInstance()
                .marshall(flaggedResourcesListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<CreateResourceRequest> marshall(CreateResourceRequest createResourceRequest) {

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

    Request<CreateResourceRequest> request =
        new DefaultRequest<CreateResourceRequest>(createResourceRequest, "AmazonApiGateway");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "/restapis/{restapi_id}/resources/{parent_id}";

    uriResourcePath =
        uriResourcePath.replace(
            "{restapi_id}",
            (createResourceRequest.getRestApiId() == null)
                ? ""
                : StringUtils.fromString(createResourceRequest.getRestApiId()));
    uriResourcePath =
        uriResourcePath.replace(
            "{parent_id}",
            (createResourceRequest.getParentId() == null)
                ? ""
                : StringUtils.fromString(createResourceRequest.getParentId()));
    request.setResourcePath(uriResourcePath);

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

      jsonWriter.object();

      if (createResourceRequest.getPathPart() != null) {
        jsonWriter.key("pathPart").value(createResourceRequest.getPathPart());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      if (!request.getHeaders().containsKey("Content-Type")) {
        request.addHeader("Content-Type", DEFAULT_CONTENT_TYPE);
      }
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(
      ConfigRuleEvaluationStatus configRuleEvaluationStatus, JSONWriter jsonWriter) {
    if (configRuleEvaluationStatus == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (configRuleEvaluationStatus.getConfigRuleName() != null) {
        jsonWriter.key("ConfigRuleName").value(configRuleEvaluationStatus.getConfigRuleName());
      }

      if (configRuleEvaluationStatus.getConfigRuleArn() != null) {
        jsonWriter.key("ConfigRuleArn").value(configRuleEvaluationStatus.getConfigRuleArn());
      }

      if (configRuleEvaluationStatus.getConfigRuleId() != null) {
        jsonWriter.key("ConfigRuleId").value(configRuleEvaluationStatus.getConfigRuleId());
      }

      if (configRuleEvaluationStatus.getLastSuccessfulInvocationTime() != null) {
        jsonWriter
            .key("LastSuccessfulInvocationTime")
            .value(configRuleEvaluationStatus.getLastSuccessfulInvocationTime());
      }

      if (configRuleEvaluationStatus.getLastFailedInvocationTime() != null) {
        jsonWriter
            .key("LastFailedInvocationTime")
            .value(configRuleEvaluationStatus.getLastFailedInvocationTime());
      }

      if (configRuleEvaluationStatus.getFirstActivatedTime() != null) {
        jsonWriter
            .key("FirstActivatedTime")
            .value(configRuleEvaluationStatus.getFirstActivatedTime());
      }

      if (configRuleEvaluationStatus.getLastErrorCode() != null) {
        jsonWriter.key("LastErrorCode").value(configRuleEvaluationStatus.getLastErrorCode());
      }

      if (configRuleEvaluationStatus.getLastErrorMessage() != null) {
        jsonWriter.key("LastErrorMessage").value(configRuleEvaluationStatus.getLastErrorMessage());
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<UpdateMaintenanceStartTimeRequest> marshall(
      UpdateMaintenanceStartTimeRequest updateMaintenanceStartTimeRequest) {

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

    Request<UpdateMaintenanceStartTimeRequest> request =
        new DefaultRequest<UpdateMaintenanceStartTimeRequest>(
            updateMaintenanceStartTimeRequest, "AWSStorageGateway");
    request.addHeader("X-Amz-Target", "StorageGateway_20130630.UpdateMaintenanceStartTime");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonWriter.object();

      if (updateMaintenanceStartTimeRequest.getGatewayARN() != null) {
        jsonWriter.key("GatewayARN").value(updateMaintenanceStartTimeRequest.getGatewayARN());
      }

      if (updateMaintenanceStartTimeRequest.getHourOfDay() != null) {
        jsonWriter.key("HourOfDay").value(updateMaintenanceStartTimeRequest.getHourOfDay());
      }

      if (updateMaintenanceStartTimeRequest.getMinuteOfHour() != null) {
        jsonWriter.key("MinuteOfHour").value(updateMaintenanceStartTimeRequest.getMinuteOfHour());
      }

      if (updateMaintenanceStartTimeRequest.getDayOfWeek() != null) {
        jsonWriter.key("DayOfWeek").value(updateMaintenanceStartTimeRequest.getDayOfWeek());
      }

      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;
  }
  public Request<ListActivityTypesRequest> marshall(
      ListActivityTypesRequest listActivityTypesRequest) {
    if (listActivityTypesRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<ListActivityTypesRequest> request =
        new DefaultRequest<ListActivityTypesRequest>(
            listActivityTypesRequest, "AmazonSimpleWorkflow");
    String target = "SimpleWorkflowService.ListActivityTypes";
    request.addHeader("X-Amz-Target", target);
    request.addHeader("Content-Type", "application/x-amz-json-1.0");
    request.setHttpMethod(POST);

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

      if (listActivityTypesRequest.getDomain() != null) {
        jsonWriter.key("domain").value(listActivityTypesRequest.getDomain());
      }
      if (listActivityTypesRequest.getName() != null) {
        jsonWriter.key("name").value(listActivityTypesRequest.getName());
      }
      if (listActivityTypesRequest.getRegistrationStatus() != null) {
        jsonWriter
            .key("registrationStatus")
            .value(listActivityTypesRequest.getRegistrationStatus());
      }
      if (listActivityTypesRequest.getNextPageToken() != null) {
        jsonWriter.key("nextPageToken").value(listActivityTypesRequest.getNextPageToken());
      }
      if (listActivityTypesRequest.getMaximumPageSize() != null) {
        jsonWriter.key("maximumPageSize").value(listActivityTypesRequest.getMaximumPageSize());
      }
      if (listActivityTypesRequest.isReverseOrder() != null) {
        jsonWriter.key("reverseOrder").value(listActivityTypesRequest.isReverseOrder());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes("UTF-8");
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      return request;
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
Exemplo n.º 23
0
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(ApiKey apiKey, JSONWriter jsonWriter) {
    if (apiKey == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (apiKey.getId() != null) {
        jsonWriter.key("id").value(apiKey.getId());
      }

      if (apiKey.getName() != null) {
        jsonWriter.key("name").value(apiKey.getName());
      }

      if (apiKey.getDescription() != null) {
        jsonWriter.key("description").value(apiKey.getDescription());
      }

      if (apiKey.getEnabled() != null) {
        jsonWriter.key("enabled").value(apiKey.getEnabled());
      }

      java.util.List<String> stageKeysList = apiKey.getStageKeys();
      if (stageKeysList != null) {
        jsonWriter.key("stageKeys");
        jsonWriter.array();
        for (String stageKeysListValue : stageKeysList) {
          if (stageKeysListValue != null) {
            jsonWriter.value(stageKeysListValue);
          }
        }
        jsonWriter.endArray();
      }

      if (apiKey.getCreatedDate() != null) {
        jsonWriter.key("createdDate").value(apiKey.getCreatedDate());
      }

      if (apiKey.getLastUpdatedDate() != null) {
        jsonWriter.key("lastUpdatedDate").value(apiKey.getLastUpdatedDate());
      }

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

    Request<PutSubscriptionFilterRequest> request =
        new DefaultRequest<PutSubscriptionFilterRequest>(putSubscriptionFilterRequest, "AWSLogs");
    String target = "Logs_20140328.PutSubscriptionFilter";
    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 (putSubscriptionFilterRequest.getLogGroupName() != null) {
        jsonWriter.key("logGroupName").value(putSubscriptionFilterRequest.getLogGroupName());
      }
      if (putSubscriptionFilterRequest.getFilterName() != null) {
        jsonWriter.key("filterName").value(putSubscriptionFilterRequest.getFilterName());
      }
      if (putSubscriptionFilterRequest.getFilterPattern() != null) {
        jsonWriter.key("filterPattern").value(putSubscriptionFilterRequest.getFilterPattern());
      }
      if (putSubscriptionFilterRequest.getDestinationArn() != null) {
        jsonWriter.key("destinationArn").value(putSubscriptionFilterRequest.getDestinationArn());
      }
      if (putSubscriptionFilterRequest.getRoleArn() != null) {
        jsonWriter.key("roleArn").value(putSubscriptionFilterRequest.getRoleArn());
      }

      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;
  }
Exemplo n.º 25
0
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(Upload upload, JSONWriter jsonWriter) {
    if (upload == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (upload.getArn() != null) {
        jsonWriter.key("arn").value(upload.getArn());
      }

      if (upload.getName() != null) {
        jsonWriter.key("name").value(upload.getName());
      }

      if (upload.getCreated() != null) {
        jsonWriter.key("created").value(upload.getCreated());
      }

      if (upload.getType() != null) {
        jsonWriter.key("type").value(upload.getType());
      }

      if (upload.getStatus() != null) {
        jsonWriter.key("status").value(upload.getStatus());
      }

      if (upload.getUrl() != null) {
        jsonWriter.key("url").value(upload.getUrl());
      }

      if (upload.getMetadata() != null) {
        jsonWriter.key("metadata").value(upload.getMetadata());
      }

      if (upload.getContentType() != null) {
        jsonWriter.key("contentType").value(upload.getContentType());
      }

      if (upload.getMessage() != null) {
        jsonWriter.key("message").value(upload.getMessage());
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<UpdateAssociationStatusRequest> marshall(
      UpdateAssociationStatusRequest updateAssociationStatusRequest) {

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

    Request<UpdateAssociationStatusRequest> request =
        new DefaultRequest<UpdateAssociationStatusRequest>(
            updateAssociationStatusRequest, "AWSSimpleSystemsManagement");
    request.addHeader("X-Amz-Target", "AmazonSSM.UpdateAssociationStatus");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonWriter.object();

      if (updateAssociationStatusRequest.getName() != null) {
        jsonWriter.key("Name").value(updateAssociationStatusRequest.getName());
      }

      if (updateAssociationStatusRequest.getInstanceId() != null) {
        jsonWriter.key("InstanceId").value(updateAssociationStatusRequest.getInstanceId());
      }

      if (updateAssociationStatusRequest.getAssociationStatus() != null) {
        jsonWriter.key("AssociationStatus");
        AssociationStatusJsonMarshaller.getInstance()
            .marshall(updateAssociationStatusRequest.getAssociationStatus(), jsonWriter);
      }

      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;
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(FileSystemDescription fileSystemDescription, JSONWriter jsonWriter) {
    if (fileSystemDescription == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (fileSystemDescription.getOwnerId() != null) {
        jsonWriter.key("OwnerId").value(fileSystemDescription.getOwnerId());
      }

      if (fileSystemDescription.getCreationToken() != null) {
        jsonWriter.key("CreationToken").value(fileSystemDescription.getCreationToken());
      }

      if (fileSystemDescription.getFileSystemId() != null) {
        jsonWriter.key("FileSystemId").value(fileSystemDescription.getFileSystemId());
      }

      if (fileSystemDescription.getCreationTime() != null) {
        jsonWriter.key("CreationTime").value(fileSystemDescription.getCreationTime());
      }

      if (fileSystemDescription.getLifeCycleState() != null) {
        jsonWriter.key("LifeCycleState").value(fileSystemDescription.getLifeCycleState());
      }

      if (fileSystemDescription.getName() != null) {
        jsonWriter.key("Name").value(fileSystemDescription.getName());
      }

      if (fileSystemDescription.getNumberOfMountTargets() != null) {
        jsonWriter
            .key("NumberOfMountTargets")
            .value(fileSystemDescription.getNumberOfMountTargets());
      }

      if (fileSystemDescription.getSizeInBytes() != null) {
        jsonWriter.key("SizeInBytes");
        FileSystemSizeJsonMarshaller.getInstance()
            .marshall(fileSystemDescription.getSizeInBytes(), jsonWriter);
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<ListApplicationsRequest> marshall(
      ListApplicationsRequest listApplicationsRequest) {

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

    Request<ListApplicationsRequest> request =
        new DefaultRequest<ListApplicationsRequest>(listApplicationsRequest, "AmazonInspector");
    request.addHeader("X-Amz-Target", "InspectorService.ListApplications");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonWriter.object();

      if (listApplicationsRequest.getFilter() != null) {
        jsonWriter.key("filter");
        ApplicationsFilterJsonMarshaller.getInstance()
            .marshall(listApplicationsRequest.getFilter(), jsonWriter);
      }

      if (listApplicationsRequest.getNextToken() != null) {
        jsonWriter.key("nextToken").value(listApplicationsRequest.getNextToken());
      }

      if (listApplicationsRequest.getMaxResults() != null) {
        jsonWriter.key("maxResults").value(listApplicationsRequest.getMaxResults());
      }

      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;
  }
  public Request<PutEventsRequest> marshall(PutEventsRequest putEventsRequest) {

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

    Request<PutEventsRequest> request =
        new DefaultRequest<PutEventsRequest>(putEventsRequest, "AmazonCloudWatchEvents");
    request.addHeader("X-Amz-Target", "AWSEvents.PutEvents");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonWriter.object();

      java.util.List<PutEventsRequestEntry> entriesList = putEventsRequest.getEntries();
      if (entriesList != null) {
        jsonWriter.key("Entries");
        jsonWriter.array();
        for (PutEventsRequestEntry entriesListValue : entriesList) {
          if (entriesListValue != null) {

            PutEventsRequestEntryJsonMarshaller.getInstance()
                .marshall(entriesListValue, 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;
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(Record record, JSONWriter jsonWriter) {
    if (record == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (record.getData() != null) {
        jsonWriter.key("Data").value(record.getData());
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }