/** 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.º 2
0
  private void writePolicy(Policy policy, JSONWriter generator) throws JSONException, IOException {
    generator.object();
    generator.key("Version").value(policy.getVersion());

    if (policy.getId() != null) {
      generator.key("Id").value(policy.getId());
    }

    generator.key("Statement").array();
    for (Statement statement : policy.getStatements()) {
      generator.object();
      if (statement.getId() != null) {
        generator.key("Sid").value(statement.getId());
      }
      generator.key("Effect").value(statement.getEffect().toString());

      writePrincipals(statement, generator);
      writeActions(statement, generator);
      writeResources(statement, generator);
      writeConditions(statement, generator);

      generator.endObject();
    }
    generator.endArray();

    generator.endObject();
  }
  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;
  }
Exemplo n.º 4
0
  /**
   * Uses the specified generator to write the JSON data for the principals in the specified policy
   * statement.
   */
  private void writePrincipals(Statement statement, JSONWriter generator)
      throws IOException, JSONException {

    List<Principal> principals = statement.getPrincipals();
    if (principals == null || principals.isEmpty()) return;

    generator.key("Principal").object();
    Map<String, List<String>> principalContentsByScheme = new HashMap<String, List<String>>();

    for (Principal p : principals) {
      List<String> principalValues = principalContentsByScheme.get(p.getProvider());

      if (principalValues == null) {
        principalValues = new ArrayList<String>();
        principalContentsByScheme.put(p.getProvider(), principalValues);
      }

      principalValues.add(p.getId());
    }

    for (Map.Entry<String, List<String>> entry : principalContentsByScheme.entrySet()) {

      String scheme = entry.getKey();
      generator.key(scheme).array();

      for (String principalId : entry.getValue()) {
        generator.value(principalId);
      }

      generator.endArray();
    }

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

    try {
      jsonWriter.object();

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

      com.amazonaws.internal.SdkInternalList<String> commandList =
          (com.amazonaws.internal.SdkInternalList<String>) containerOverride.getCommand();
      if (!commandList.isEmpty() || !commandList.isAutoConstruct()) {
        jsonWriter.key("command");
        jsonWriter.array();
        for (String commandListValue : commandList) {
          if (commandListValue != null) {
            jsonWriter.value(commandListValue);
          }
        }
        jsonWriter.endArray();
      }

      com.amazonaws.internal.SdkInternalList<KeyValuePair> environmentList =
          (com.amazonaws.internal.SdkInternalList<KeyValuePair>) containerOverride.getEnvironment();
      if (!environmentList.isEmpty() || !environmentList.isAutoConstruct()) {
        jsonWriter.key("environment");
        jsonWriter.array();
        for (KeyValuePair environmentListValue : environmentList) {
          if (environmentListValue != null) {

            KeyValuePairJsonMarshaller.getInstance().marshall(environmentListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
Exemplo n.º 8
0
  private void writeActions(Statement statement, JSONWriter generator)
      throws IOException, JSONException {
    List<Action> actions = statement.getActions();
    if (actions == null || actions.isEmpty()) return;

    generator.key("Action").array();
    for (Action action : actions) {
      generator.value(action.getActionName());
    }
    generator.endArray();
  }
Exemplo n.º 9
0
  private void writeResources(Statement statement, JSONWriter generator)
      throws IOException, JSONException {
    List<Resource> resources = statement.getResources();
    if (resources == null || resources.isEmpty()) return;

    generator.key("Resource").array();
    for (Resource resource : resources) {
      generator.value(resource.getId());
    }
    generator.endArray();
  }
  /** 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);
    }
  }
Exemplo n.º 11
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<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(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(WebACL webACL, JSONWriter jsonWriter) {
    if (webACL == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (webACL.getWebACLId() != null) {
        jsonWriter.key("WebACLId").value(webACL.getWebACLId());
      }

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

      if (webACL.getMetricName() != null) {
        jsonWriter.key("MetricName").value(webACL.getMetricName());
      }

      if (webACL.getDefaultAction() != null) {
        jsonWriter.key("DefaultAction");
        WafActionJsonMarshaller.getInstance().marshall(webACL.getDefaultAction(), jsonWriter);
      }

      java.util.List<ActivatedRule> rulesList = webACL.getRules();
      if (rulesList != null) {
        jsonWriter.key("Rules");
        jsonWriter.array();
        for (ActivatedRule rulesListValue : rulesList) {
          if (rulesListValue != null) {

            ActivatedRuleJsonMarshaller.getInstance().marshall(rulesListValue, 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(PutEventsRequestEntry putEventsRequestEntry, JSONWriter jsonWriter) {
    if (putEventsRequestEntry == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (putEventsRequestEntry.getTime() != null) {
        jsonWriter.key("Time").value(putEventsRequestEntry.getTime());
      }

      if (putEventsRequestEntry.getSource() != null) {
        jsonWriter.key("Source").value(putEventsRequestEntry.getSource());
      }

      java.util.List<String> resourcesList = putEventsRequestEntry.getResources();
      if (resourcesList != null) {
        jsonWriter.key("Resources");
        jsonWriter.array();
        for (String resourcesListValue : resourcesList) {
          if (resourcesListValue != null) {
            jsonWriter.value(resourcesListValue);
          }
        }
        jsonWriter.endArray();
      }

      if (putEventsRequestEntry.getDetailType() != null) {
        jsonWriter.key("DetailType").value(putEventsRequestEntry.getDetailType());
      }

      if (putEventsRequestEntry.getDetail() != null) {
        jsonWriter.key("Detail").value(putEventsRequestEntry.getDetail());
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
Exemplo n.º 16
0
  private void writeConditions(final List<Condition> conditions, final JSONWriter generator)
      throws IOException, JSONException {

    /*
     * We could also have multiple conditions that use the same type and
     * same key, in which case, we need to push them together as one entry
     * when we send the JSON representation.
     */
    Map<String, List<String>> conditionValuesByKey = sortConditionsByKey(conditions);

    for (Map.Entry<String, List<String>> entry : conditionValuesByKey.entrySet()) {

      String conditionKey = entry.getKey();
      generator.key(conditionKey).array();

      for (String value : entry.getValue()) {
        generator.value(value);
      }

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

    try {
      jsonWriter.object();

      if (sqlInjectionMatchSet.getSqlInjectionMatchSetId() != null) {
        jsonWriter
            .key("SqlInjectionMatchSetId")
            .value(sqlInjectionMatchSet.getSqlInjectionMatchSetId());
      }

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

      java.util.List<SqlInjectionMatchTuple> sqlInjectionMatchTuplesList =
          sqlInjectionMatchSet.getSqlInjectionMatchTuples();
      if (sqlInjectionMatchTuplesList != null) {
        jsonWriter.key("SqlInjectionMatchTuples");
        jsonWriter.array();
        for (SqlInjectionMatchTuple sqlInjectionMatchTuplesListValue :
            sqlInjectionMatchTuplesList) {
          if (sqlInjectionMatchTuplesListValue != null) {

            SqlInjectionMatchTupleJsonMarshaller.getInstance()
                .marshall(sqlInjectionMatchTuplesListValue, 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(Scope scope, JSONWriter jsonWriter) {
    if (scope == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      com.amazonaws.internal.SdkInternalList<String> complianceResourceTypesList =
          (com.amazonaws.internal.SdkInternalList<String>) scope.getComplianceResourceTypes();
      if (!complianceResourceTypesList.isEmpty()
          || !complianceResourceTypesList.isAutoConstruct()) {
        jsonWriter.key("ComplianceResourceTypes");
        jsonWriter.array();
        for (String complianceResourceTypesListValue : complianceResourceTypesList) {
          if (complianceResourceTypesListValue != null) {
            jsonWriter.value(complianceResourceTypesListValue);
          }
        }
        jsonWriter.endArray();
      }

      if (scope.getTagKey() != null) {
        jsonWriter.key("TagKey").value(scope.getTagKey());
      }

      if (scope.getTagValue() != null) {
        jsonWriter.key("TagValue").value(scope.getTagValue());
      }

      if (scope.getComplianceResourceId() != null) {
        jsonWriter.key("ComplianceResourceId").value(scope.getComplianceResourceId());
      }

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

    Request<AddUploadBufferRequest> request =
        new DefaultRequest<AddUploadBufferRequest>(addUploadBufferRequest, "AWSStorageGateway");
    String target = "StorageGateway_20130630.AddUploadBuffer";
    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 (addUploadBufferRequest.getGatewayARN() != null) {
        jsonWriter.key("GatewayARN").value(addUploadBufferRequest.getGatewayARN());
      }

      com.amazonaws.internal.ListWithAutoConstructFlag<String> diskIdsList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<String>)
              (addUploadBufferRequest.getDiskIds());
      if (diskIdsList != null && !(diskIdsList.isAutoConstruct() && diskIdsList.isEmpty())) {

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

        for (String diskIdsListValue : diskIdsList) {
          if (diskIdsListValue != null) {
            jsonWriter.value(diskIdsListValue);
          }
        }
        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));
    } 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(TaskDefinition taskDefinition, JSONWriter jsonWriter) {
    if (taskDefinition == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (taskDefinition.getTaskDefinitionArn() != null) {
        jsonWriter.key("taskDefinitionArn").value(taskDefinition.getTaskDefinitionArn());
      }

      com.amazonaws.internal.SdkInternalList<ContainerDefinition> containerDefinitionsList =
          (com.amazonaws.internal.SdkInternalList<ContainerDefinition>)
              taskDefinition.getContainerDefinitions();
      if (!containerDefinitionsList.isEmpty() || !containerDefinitionsList.isAutoConstruct()) {
        jsonWriter.key("containerDefinitions");
        jsonWriter.array();
        for (ContainerDefinition containerDefinitionsListValue : containerDefinitionsList) {
          if (containerDefinitionsListValue != null) {

            ContainerDefinitionJsonMarshaller.getInstance()
                .marshall(containerDefinitionsListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      if (taskDefinition.getFamily() != null) {
        jsonWriter.key("family").value(taskDefinition.getFamily());
      }

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

      com.amazonaws.internal.SdkInternalList<Volume> volumesList =
          (com.amazonaws.internal.SdkInternalList<Volume>) taskDefinition.getVolumes();
      if (!volumesList.isEmpty() || !volumesList.isAutoConstruct()) {
        jsonWriter.key("volumes");
        jsonWriter.array();
        for (Volume volumesListValue : volumesList) {
          if (volumesListValue != null) {

            VolumeJsonMarshaller.getInstance().marshall(volumesListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

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

      com.amazonaws.internal.SdkInternalList<Attribute> requiresAttributesList =
          (com.amazonaws.internal.SdkInternalList<Attribute>)
              taskDefinition.getRequiresAttributes();
      if (!requiresAttributesList.isEmpty() || !requiresAttributesList.isAutoConstruct()) {
        jsonWriter.key("requiresAttributes");
        jsonWriter.array();
        for (Attribute requiresAttributesListValue : requiresAttributesList) {
          if (requiresAttributesListValue != null) {

            AttributeJsonMarshaller.getInstance().marshall(requiresAttributesListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

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

    Request<CreateInstanceRequest> request =
        new DefaultRequest<CreateInstanceRequest>(createInstanceRequest, "AWSOpsWorks");
    String target = "OpsWorks_20130218.CreateInstance";
    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 (createInstanceRequest.getStackId() != null) {
        jsonWriter.key("StackId").value(createInstanceRequest.getStackId());
      }

      com.amazonaws.internal.ListWithAutoConstructFlag<String> layerIdsList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<String>)
              (createInstanceRequest.getLayerIds());
      if (layerIdsList != null && !(layerIdsList.isAutoConstruct() && layerIdsList.isEmpty())) {

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

        for (String layerIdsListValue : layerIdsList) {
          if (layerIdsListValue != null) {
            jsonWriter.value(layerIdsListValue);
          }
        }
        jsonWriter.endArray();
      }
      if (createInstanceRequest.getInstanceType() != null) {
        jsonWriter.key("InstanceType").value(createInstanceRequest.getInstanceType());
      }
      if (createInstanceRequest.getAutoScalingType() != null) {
        jsonWriter.key("AutoScalingType").value(createInstanceRequest.getAutoScalingType());
      }
      if (createInstanceRequest.getHostname() != null) {
        jsonWriter.key("Hostname").value(createInstanceRequest.getHostname());
      }
      if (createInstanceRequest.getOs() != null) {
        jsonWriter.key("Os").value(createInstanceRequest.getOs());
      }
      if (createInstanceRequest.getAmiId() != null) {
        jsonWriter.key("AmiId").value(createInstanceRequest.getAmiId());
      }
      if (createInstanceRequest.getSshKeyName() != null) {
        jsonWriter.key("SshKeyName").value(createInstanceRequest.getSshKeyName());
      }
      if (createInstanceRequest.getAvailabilityZone() != null) {
        jsonWriter.key("AvailabilityZone").value(createInstanceRequest.getAvailabilityZone());
      }
      if (createInstanceRequest.getVirtualizationType() != null) {
        jsonWriter.key("VirtualizationType").value(createInstanceRequest.getVirtualizationType());
      }
      if (createInstanceRequest.getSubnetId() != null) {
        jsonWriter.key("SubnetId").value(createInstanceRequest.getSubnetId());
      }
      if (createInstanceRequest.getArchitecture() != null) {
        jsonWriter.key("Architecture").value(createInstanceRequest.getArchitecture());
      }
      if (createInstanceRequest.getRootDeviceType() != null) {
        jsonWriter.key("RootDeviceType").value(createInstanceRequest.getRootDeviceType());
      }

      com.amazonaws.internal.ListWithAutoConstructFlag<BlockDeviceMapping> blockDeviceMappingsList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<BlockDeviceMapping>)
              (createInstanceRequest.getBlockDeviceMappings());
      if (blockDeviceMappingsList != null
          && !(blockDeviceMappingsList.isAutoConstruct() && blockDeviceMappingsList.isEmpty())) {

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

        for (BlockDeviceMapping blockDeviceMappingsListValue : blockDeviceMappingsList) {
          if (blockDeviceMappingsListValue != null) {
            jsonWriter.object();
            if (blockDeviceMappingsListValue.getDeviceName() != null) {
              jsonWriter.key("DeviceName").value(blockDeviceMappingsListValue.getDeviceName());
            }
            if (blockDeviceMappingsListValue.getNoDevice() != null) {
              jsonWriter.key("NoDevice").value(blockDeviceMappingsListValue.getNoDevice());
            }
            if (blockDeviceMappingsListValue.getVirtualName() != null) {
              jsonWriter.key("VirtualName").value(blockDeviceMappingsListValue.getVirtualName());
            }
            EbsBlockDevice ebs = blockDeviceMappingsListValue.getEbs();
            if (ebs != null) {

              jsonWriter.key("Ebs");
              jsonWriter.object();

              if (ebs.getSnapshotId() != null) {
                jsonWriter.key("SnapshotId").value(ebs.getSnapshotId());
              }
              if (ebs.getIops() != null) {
                jsonWriter.key("Iops").value(ebs.getIops());
              }
              if (ebs.getVolumeSize() != null) {
                jsonWriter.key("VolumeSize").value(ebs.getVolumeSize());
              }
              if (ebs.getVolumeType() != null) {
                jsonWriter.key("VolumeType").value(ebs.getVolumeType());
              }
              if (ebs.isDeleteOnTermination() != null) {
                jsonWriter.key("DeleteOnTermination").value(ebs.isDeleteOnTermination());
              }
              jsonWriter.endObject();
            }
            jsonWriter.endObject();
          }
        }
        jsonWriter.endArray();
      }
      if (createInstanceRequest.isInstallUpdatesOnBoot() != null) {
        jsonWriter
            .key("InstallUpdatesOnBoot")
            .value(createInstanceRequest.isInstallUpdatesOnBoot());
      }
      if (createInstanceRequest.isEbsOptimized() != null) {
        jsonWriter.key("EbsOptimized").value(createInstanceRequest.isEbsOptimized());
      }
      if (createInstanceRequest.getAgentVersion() != null) {
        jsonWriter.key("AgentVersion").value(createInstanceRequest.getAgentVersion());
      }

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

    Request<CreateDeploymentRequest> request =
        new DefaultRequest<CreateDeploymentRequest>(createDeploymentRequest, "AWSOpsWorks");
    String target = "OpsWorks_20130218.CreateDeployment";
    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 (createDeploymentRequest.getStackId() != null) {
        jsonWriter.key("StackId").value(createDeploymentRequest.getStackId());
      }
      if (createDeploymentRequest.getAppId() != null) {
        jsonWriter.key("AppId").value(createDeploymentRequest.getAppId());
      }

      java.util.List<String> instanceIdsList = createDeploymentRequest.getInstanceIds();
      if (instanceIdsList != null && instanceIdsList.size() > 0) {

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

        for (String instanceIdsListValue : instanceIdsList) {
          if (instanceIdsListValue != null) {
            jsonWriter.value(instanceIdsListValue);
          }
        }
        jsonWriter.endArray();
      }
      DeploymentCommand command = createDeploymentRequest.getCommand();
      if (command != null) {

        jsonWriter.key("Command");
        jsonWriter.object();

        if (command.getName() != null) {
          jsonWriter.key("Name").value(command.getName());
        }
        if (command.getArgs() != null) {
          jsonWriter.key("Args");
          jsonWriter.object();
          for (Map.Entry<String, java.util.List<String>> argsListValue :
              command.getArgs().entrySet()) {
            if (argsListValue.getValue() != null) {
              jsonWriter.key(argsListValue.getKey());
            }
          }
          jsonWriter.endObject();
        }
        jsonWriter.endObject();
      }
      if (createDeploymentRequest.getComment() != null) {
        jsonWriter.key("Comment").value(createDeploymentRequest.getComment());
      }
      if (createDeploymentRequest.getCustomJson() != null) {
        jsonWriter.key("CustomJson").value(createDeploymentRequest.getCustomJson());
      }

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

    Request<DescribeTimeBasedAutoScalingRequest> request =
        new DefaultRequest<DescribeTimeBasedAutoScalingRequest>(
            describeTimeBasedAutoScalingRequest, "AWSOpsWorks");
    String target = "OpsWorks_20130218.DescribeTimeBasedAutoScaling";
    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();

      java.util.List<String> instanceIdsList = describeTimeBasedAutoScalingRequest.getInstanceIds();
      if (instanceIdsList != null) {

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

        for (String instanceIdsListValue : instanceIdsList) {
          if (instanceIdsListValue != null) {
            jsonWriter.value(instanceIdsListValue);
          }
        }
        jsonWriter.endArray();
      }

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

    Request<UpdateRecordsRequest> request =
        new DefaultRequest<UpdateRecordsRequest>(updateRecordsRequest, "AmazonCognitoSync");
    String target = "AWSCognitoSyncService.UpdateRecords";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    if (updateRecordsRequest.getClientContext() != null)
      request.addHeader(
          "x-amz-Client-Context", StringUtils.fromString(updateRecordsRequest.getClientContext()));

    String uriResourcePath = RESOURCE_PATH_TEMPLATE;

    if (DYNAMIC_QUERY_PARAMS.containsKey("IdentityPoolId")) {
      String name = DYNAMIC_QUERY_PARAMS.get("IdentityPoolId");
      String value =
          (updateRecordsRequest.getIdentityPoolId() == null)
              ? null
              : StringUtils.fromString(updateRecordsRequest.getIdentityPoolId());

      if (!(value == null || value.isEmpty())) {
        request.addParameter(name, value);
      }
    } else {
      uriResourcePath =
          uriResourcePath.replace(
              "{IdentityPoolId}",
              (updateRecordsRequest.getIdentityPoolId() == null)
                  ? ""
                  : StringUtils.fromString(updateRecordsRequest.getIdentityPoolId()));
    }

    if (DYNAMIC_QUERY_PARAMS.containsKey("IdentityId")) {
      String name = DYNAMIC_QUERY_PARAMS.get("IdentityId");
      String value =
          (updateRecordsRequest.getIdentityId() == null)
              ? null
              : StringUtils.fromString(updateRecordsRequest.getIdentityId());

      if (!(value == null || value.isEmpty())) {
        request.addParameter(name, value);
      }
    } else {
      uriResourcePath =
          uriResourcePath.replace(
              "{IdentityId}",
              (updateRecordsRequest.getIdentityId() == null)
                  ? ""
                  : StringUtils.fromString(updateRecordsRequest.getIdentityId()));
    }

    if (DYNAMIC_QUERY_PARAMS.containsKey("DatasetName")) {
      String name = DYNAMIC_QUERY_PARAMS.get("DatasetName");
      String value =
          (updateRecordsRequest.getDatasetName() == null)
              ? null
              : StringUtils.fromString(updateRecordsRequest.getDatasetName());

      if (!(value == null || value.isEmpty())) {
        request.addParameter(name, value);
      }
    } else {
      uriResourcePath =
          uriResourcePath.replace(
              "{DatasetName}",
              (updateRecordsRequest.getDatasetName() == null)
                  ? ""
                  : StringUtils.fromString(updateRecordsRequest.getDatasetName()));
    }

    request.setResourcePath(uriResourcePath.replaceAll("//", "/"));

    for (Map.Entry<String, String> entry : STATIC_QUERY_PARAMS.entrySet()) {
      request.addParameter(entry.getKey(), entry.getValue());
    }

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

      jsonWriter.object();

      com.amazonaws.internal.ListWithAutoConstructFlag<RecordPatch> recordPatchesList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<RecordPatch>)
              (updateRecordsRequest.getRecordPatches());
      if (recordPatchesList != null
          && !(recordPatchesList.isAutoConstruct() && recordPatchesList.isEmpty())) {

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

        for (RecordPatch recordPatchesListValue : recordPatchesList) {
          if (recordPatchesListValue != null) {
            jsonWriter.object();
            if (recordPatchesListValue.getOp() != null) {
              jsonWriter.key("Op").value(recordPatchesListValue.getOp());
            }
            if (recordPatchesListValue.getKey() != null) {
              jsonWriter.key("Key").value(recordPatchesListValue.getKey());
            }
            if (recordPatchesListValue.getValue() != null) {
              jsonWriter.key("Value").value(recordPatchesListValue.getValue());
            }
            if (recordPatchesListValue.getSyncCount() != null) {
              jsonWriter.key("SyncCount").value(recordPatchesListValue.getSyncCount());
            }
            if (recordPatchesListValue.getDeviceLastModifiedDate() != null) {
              jsonWriter
                  .key("DeviceLastModifiedDate")
                  .value(recordPatchesListValue.getDeviceLastModifiedDate());
            }
            jsonWriter.endObject();
          }
        }
        jsonWriter.endArray();
      }
      if (updateRecordsRequest.getSyncSessionToken() != null) {
        jsonWriter.key("SyncSessionToken").value(updateRecordsRequest.getSyncSessionToken());
      }

      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<UpdateBasePathMappingRequest> marshall(
      UpdateBasePathMappingRequest updateBasePathMappingRequest) {

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

    Request<UpdateBasePathMappingRequest> request =
        new DefaultRequest<UpdateBasePathMappingRequest>(
            updateBasePathMappingRequest, "AmazonApiGateway");

    request.setHttpMethod(HttpMethodName.PATCH);

    String uriResourcePath = "/domainnames/{domain_name}/basepathmappings/{base_path}";

    uriResourcePath =
        uriResourcePath.replace(
            "{domain_name}",
            (updateBasePathMappingRequest.getDomainName() == null)
                ? ""
                : StringUtils.fromString(updateBasePathMappingRequest.getDomainName()));
    uriResourcePath =
        uriResourcePath.replace(
            "{base_path}",
            (updateBasePathMappingRequest.getBasePath() == null)
                ? ""
                : StringUtils.fromString(updateBasePathMappingRequest.getBasePath()));
    request.setResourcePath(uriResourcePath);

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

      jsonWriter.object();

      java.util.List<PatchOperation> patchOperationsList =
          updateBasePathMappingRequest.getPatchOperations();
      if (patchOperationsList != null) {
        jsonWriter.key("patchOperations");
        jsonWriter.array();
        for (PatchOperation patchOperationsListValue : patchOperationsList) {
          if (patchOperationsListValue != null) {

            PatchOperationJsonMarshaller.getInstance()
                .marshall(patchOperationsListValue, 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));
      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;
  }
  public Request<StartWorkflowExecutionRequest> marshall(
      StartWorkflowExecutionRequest startWorkflowExecutionRequest) {
    if (startWorkflowExecutionRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<StartWorkflowExecutionRequest> request =
        new DefaultRequest<StartWorkflowExecutionRequest>(
            startWorkflowExecutionRequest, "AmazonSimpleWorkflow");
    String target = "SimpleWorkflowService.StartWorkflowExecution";
    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 (startWorkflowExecutionRequest.getDomain() != null) {
        jsonWriter.key("domain").value(startWorkflowExecutionRequest.getDomain());
      }
      if (startWorkflowExecutionRequest.getWorkflowId() != null) {
        jsonWriter.key("workflowId").value(startWorkflowExecutionRequest.getWorkflowId());
      }
      WorkflowType workflowType = startWorkflowExecutionRequest.getWorkflowType();
      if (workflowType != null) {

        jsonWriter.key("workflowType");
        jsonWriter.object();

        if (workflowType.getName() != null) {
          jsonWriter.key("name").value(workflowType.getName());
        }
        if (workflowType.getVersion() != null) {
          jsonWriter.key("version").value(workflowType.getVersion());
        }
        jsonWriter.endObject();
      }
      TaskList taskList = startWorkflowExecutionRequest.getTaskList();
      if (taskList != null) {

        jsonWriter.key("taskList");
        jsonWriter.object();

        if (taskList.getName() != null) {
          jsonWriter.key("name").value(taskList.getName());
        }
        jsonWriter.endObject();
      }
      if (startWorkflowExecutionRequest.getInput() != null) {
        jsonWriter.key("input").value(startWorkflowExecutionRequest.getInput());
      }
      if (startWorkflowExecutionRequest.getExecutionStartToCloseTimeout() != null) {
        jsonWriter
            .key("executionStartToCloseTimeout")
            .value(startWorkflowExecutionRequest.getExecutionStartToCloseTimeout());
      }

      com.amazonaws.internal.ListWithAutoConstructFlag<String> tagListList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<String>)
              (startWorkflowExecutionRequest.getTagList());
      if (tagListList != null && !(tagListList.isAutoConstruct() && tagListList.isEmpty())) {

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

        for (String tagListListValue : tagListList) {
          if (tagListListValue != null) {
            jsonWriter.value(tagListListValue);
          }
        }
        jsonWriter.endArray();
      }
      if (startWorkflowExecutionRequest.getTaskStartToCloseTimeout() != null) {
        jsonWriter
            .key("taskStartToCloseTimeout")
            .value(startWorkflowExecutionRequest.getTaskStartToCloseTimeout());
      }
      if (startWorkflowExecutionRequest.getChildPolicy() != null) {
        jsonWriter.key("childPolicy").value(startWorkflowExecutionRequest.getChildPolicy());
      }

      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<DescribeInstanceInformationRequest> marshall(
      DescribeInstanceInformationRequest describeInstanceInformationRequest) {

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

    Request<DescribeInstanceInformationRequest> request =
        new DefaultRequest<DescribeInstanceInformationRequest>(
            describeInstanceInformationRequest, "AWSSimpleSystemsManagement");
    request.addHeader("X-Amz-Target", "AmazonSSM.DescribeInstanceInformation");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonWriter.object();

      com.amazonaws.internal.SdkInternalList<InstanceInformationFilter>
          instanceInformationFilterListList =
              (com.amazonaws.internal.SdkInternalList<InstanceInformationFilter>)
                  describeInstanceInformationRequest.getInstanceInformationFilterList();
      if (!instanceInformationFilterListList.isEmpty()
          || !instanceInformationFilterListList.isAutoConstruct()) {
        jsonWriter.key("InstanceInformationFilterList");
        jsonWriter.array();
        for (InstanceInformationFilter instanceInformationFilterListListValue :
            instanceInformationFilterListList) {
          if (instanceInformationFilterListListValue != null) {

            InstanceInformationFilterJsonMarshaller.getInstance()
                .marshall(instanceInformationFilterListListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      if (describeInstanceInformationRequest.getMaxResults() != null) {
        jsonWriter.key("MaxResults").value(describeInstanceInformationRequest.getMaxResults());
      }

      if (describeInstanceInformationRequest.getNextToken() != null) {
        jsonWriter.key("NextToken").value(describeInstanceInformationRequest.getNextToken());
      }

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

    Request<BatchGetItemRequest> request =
        new DefaultRequest<BatchGetItemRequest>(batchGetItemRequest, "AmazonDynamoDB");
    String target = "DynamoDB_20111205.BatchGetItem";
    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 (batchGetItemRequest.getRequestItems() != null) {
        jsonWriter.key("RequestItems");
        jsonWriter.object();
        for (Map.Entry<String, KeysAndAttributes> requestItemsListValue :
            batchGetItemRequest.getRequestItems().entrySet()) {
          if (requestItemsListValue.getValue() != null) {
            jsonWriter.key(requestItemsListValue.getKey());

            jsonWriter.object();

            java.util.List<Key> keysList = requestItemsListValue.getValue().getKeys();
            if (keysList != null && keysList.size() > 0) {

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

              for (Key keysListValue : keysList) {
                if (keysListValue != null) {
                  jsonWriter.object();
                  AttributeValue hashKeyElement = keysListValue.getHashKeyElement();
                  if (hashKeyElement != null) {

                    jsonWriter.key("HashKeyElement");
                    jsonWriter.object();

                    if (hashKeyElement.getS() != null) {
                      jsonWriter.key("S").value(hashKeyElement.getS());
                    }
                    if (hashKeyElement.getN() != null) {
                      jsonWriter.key("N").value(hashKeyElement.getN());
                    }
                    if (hashKeyElement.getB() != null) {
                      jsonWriter.key("B").value(hashKeyElement.getB());
                    }

                    java.util.List<String> sSList = hashKeyElement.getSS();
                    if (sSList != null && sSList.size() > 0) {

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

                      for (String sSListValue : sSList) {
                        if (sSListValue != null) {
                          jsonWriter.value(sSListValue);
                        }
                      }
                      jsonWriter.endArray();
                    }

                    java.util.List<String> nSList = hashKeyElement.getNS();
                    if (nSList != null && nSList.size() > 0) {

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

                      for (String nSListValue : nSList) {
                        if (nSListValue != null) {
                          jsonWriter.value(nSListValue);
                        }
                      }
                      jsonWriter.endArray();
                    }

                    java.util.List<java.nio.ByteBuffer> bSList = hashKeyElement.getBS();
                    if (bSList != null && bSList.size() > 0) {

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

                      for (java.nio.ByteBuffer bSListValue : bSList) {
                        if (bSListValue != null) {
                          jsonWriter.value(bSListValue);
                        }
                      }
                      jsonWriter.endArray();
                    }
                    jsonWriter.endObject();
                  }
                  AttributeValue rangeKeyElement = keysListValue.getRangeKeyElement();
                  if (rangeKeyElement != null) {

                    jsonWriter.key("RangeKeyElement");
                    jsonWriter.object();

                    if (rangeKeyElement.getS() != null) {
                      jsonWriter.key("S").value(rangeKeyElement.getS());
                    }
                    if (rangeKeyElement.getN() != null) {
                      jsonWriter.key("N").value(rangeKeyElement.getN());
                    }
                    if (rangeKeyElement.getB() != null) {
                      jsonWriter.key("B").value(rangeKeyElement.getB());
                    }

                    java.util.List<String> sSList = rangeKeyElement.getSS();
                    if (sSList != null && sSList.size() > 0) {

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

                      for (String sSListValue : sSList) {
                        if (sSListValue != null) {
                          jsonWriter.value(sSListValue);
                        }
                      }
                      jsonWriter.endArray();
                    }

                    java.util.List<String> nSList = rangeKeyElement.getNS();
                    if (nSList != null && nSList.size() > 0) {

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

                      for (String nSListValue : nSList) {
                        if (nSListValue != null) {
                          jsonWriter.value(nSListValue);
                        }
                      }
                      jsonWriter.endArray();
                    }

                    java.util.List<java.nio.ByteBuffer> bSList = rangeKeyElement.getBS();
                    if (bSList != null && bSList.size() > 0) {

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

                      for (java.nio.ByteBuffer bSListValue : bSList) {
                        if (bSListValue != null) {
                          jsonWriter.value(bSListValue);
                        }
                      }
                      jsonWriter.endArray();
                    }
                    jsonWriter.endObject();
                  }
                  jsonWriter.endObject();
                }
              }
              jsonWriter.endArray();
            }

            java.util.List<String> attributesToGetList =
                requestItemsListValue.getValue().getAttributesToGet();
            if (attributesToGetList != null && attributesToGetList.size() > 0) {

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

              for (String attributesToGetListValue : attributesToGetList) {
                if (attributesToGetListValue != null) {
                  jsonWriter.value(attributesToGetListValue);
                }
              }
              jsonWriter.endArray();
            }
            if (requestItemsListValue.getValue().isConsistentRead() != null) {
              jsonWriter
                  .key("ConsistentRead")
                  .value(requestItemsListValue.getValue().isConsistentRead());
            }
            jsonWriter.endObject();
          }
        }
        jsonWriter.endObject();
      }

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

    Request<SetStatusRequest> request =
        new DefaultRequest<SetStatusRequest>(setStatusRequest, "DataPipeline");
    String target = "DataPipeline.SetStatus";
    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 (setStatusRequest.getPipelineId() != null) {
        jsonWriter.key("pipelineId").value(setStatusRequest.getPipelineId());
      }

      com.amazonaws.internal.ListWithAutoConstructFlag<String> objectIdsList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<String>)
              (setStatusRequest.getObjectIds());
      if (objectIdsList != null && !(objectIdsList.isAutoConstruct() && objectIdsList.isEmpty())) {

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

        for (String objectIdsListValue : objectIdsList) {
          if (objectIdsListValue != null) {
            jsonWriter.value(objectIdsListValue);
          }
        }
        jsonWriter.endArray();
      }
      if (setStatusRequest.getStatus() != null) {
        jsonWriter.key("status").value(setStatusRequest.getStatus());
      }

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

    Request<CreateJobRequest> request =
        new DefaultRequest<CreateJobRequest>(createJobRequest, "AmazonElasticTranscoder");
    String target = "EtsCustomerService.CreateJob";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    String uriResourcePath = "2012-09-25/jobs";

    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) {
          if (!(nameValuePair[1].isEmpty()))
            request.addParameter(nameValuePair[0], nameValuePair[1]);
        }
      }
    }
    request.setResourcePath(uriResourcePath);

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

      jsonWriter.object();

      if (createJobRequest.getPipelineId() != null) {
        jsonWriter.key("PipelineId").value(createJobRequest.getPipelineId());
      }
      JobInput input = createJobRequest.getInput();
      if (input != null) {

        jsonWriter.key("Input");
        jsonWriter.object();

        if (input.getKey() != null) {
          jsonWriter.key("Key").value(input.getKey());
        }
        if (input.getFrameRate() != null) {
          jsonWriter.key("FrameRate").value(input.getFrameRate());
        }
        if (input.getResolution() != null) {
          jsonWriter.key("Resolution").value(input.getResolution());
        }
        if (input.getAspectRatio() != null) {
          jsonWriter.key("AspectRatio").value(input.getAspectRatio());
        }
        if (input.getInterlaced() != null) {
          jsonWriter.key("Interlaced").value(input.getInterlaced());
        }
        if (input.getContainer() != null) {
          jsonWriter.key("Container").value(input.getContainer());
        }
        jsonWriter.endObject();
      }
      CreateJobOutput output = createJobRequest.getOutput();
      if (output != null) {

        jsonWriter.key("Output");
        jsonWriter.object();

        if (output.getKey() != null) {
          jsonWriter.key("Key").value(output.getKey());
        }
        if (output.getThumbnailPattern() != null) {
          jsonWriter.key("ThumbnailPattern").value(output.getThumbnailPattern());
        }
        if (output.getRotate() != null) {
          jsonWriter.key("Rotate").value(output.getRotate());
        }
        if (output.getPresetId() != null) {
          jsonWriter.key("PresetId").value(output.getPresetId());
        }
        if (output.getSegmentDuration() != null) {
          jsonWriter.key("SegmentDuration").value(output.getSegmentDuration());
        }

        com.amazonaws.internal.ListWithAutoConstructFlag<JobWatermark> watermarksList =
            (com.amazonaws.internal.ListWithAutoConstructFlag<JobWatermark>)
                (output.getWatermarks());
        if (watermarksList != null
            && !(watermarksList.isAutoConstruct() && watermarksList.isEmpty())) {

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

          for (JobWatermark watermarksListValue : watermarksList) {
            if (watermarksListValue != null) {
              jsonWriter.object();
              if (watermarksListValue.getPresetWatermarkId() != null) {
                jsonWriter
                    .key("PresetWatermarkId")
                    .value(watermarksListValue.getPresetWatermarkId());
              }
              if (watermarksListValue.getInputKey() != null) {
                jsonWriter.key("InputKey").value(watermarksListValue.getInputKey());
              }
              jsonWriter.endObject();
            }
          }
          jsonWriter.endArray();
        }
        JobAlbumArt albumArt = output.getAlbumArt();
        if (albumArt != null) {

          jsonWriter.key("AlbumArt");
          jsonWriter.object();

          if (albumArt.getMergePolicy() != null) {
            jsonWriter.key("MergePolicy").value(albumArt.getMergePolicy());
          }

          com.amazonaws.internal.ListWithAutoConstructFlag<Artwork> artworkList =
              (com.amazonaws.internal.ListWithAutoConstructFlag<Artwork>) (albumArt.getArtwork());
          if (artworkList != null && !(artworkList.isAutoConstruct() && artworkList.isEmpty())) {

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

            for (Artwork artworkListValue : artworkList) {
              if (artworkListValue != null) {
                jsonWriter.object();
                if (artworkListValue.getInputKey() != null) {
                  jsonWriter.key("InputKey").value(artworkListValue.getInputKey());
                }
                if (artworkListValue.getMaxWidth() != null) {
                  jsonWriter.key("MaxWidth").value(artworkListValue.getMaxWidth());
                }
                if (artworkListValue.getMaxHeight() != null) {
                  jsonWriter.key("MaxHeight").value(artworkListValue.getMaxHeight());
                }
                if (artworkListValue.getSizingPolicy() != null) {
                  jsonWriter.key("SizingPolicy").value(artworkListValue.getSizingPolicy());
                }
                if (artworkListValue.getPaddingPolicy() != null) {
                  jsonWriter.key("PaddingPolicy").value(artworkListValue.getPaddingPolicy());
                }
                if (artworkListValue.getAlbumArtFormat() != null) {
                  jsonWriter.key("AlbumArtFormat").value(artworkListValue.getAlbumArtFormat());
                }
                jsonWriter.endObject();
              }
            }
            jsonWriter.endArray();
          }
          jsonWriter.endObject();
        }

        com.amazonaws.internal.ListWithAutoConstructFlag<Clip> compositionList =
            (com.amazonaws.internal.ListWithAutoConstructFlag<Clip>) (output.getComposition());
        if (compositionList != null
            && !(compositionList.isAutoConstruct() && compositionList.isEmpty())) {

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

          for (Clip compositionListValue : compositionList) {
            if (compositionListValue != null) {
              jsonWriter.object();
              TimeSpan timeSpan = compositionListValue.getTimeSpan();
              if (timeSpan != null) {

                jsonWriter.key("TimeSpan");
                jsonWriter.object();

                if (timeSpan.getStartTime() != null) {
                  jsonWriter.key("StartTime").value(timeSpan.getStartTime());
                }
                if (timeSpan.getDuration() != null) {
                  jsonWriter.key("Duration").value(timeSpan.getDuration());
                }
                jsonWriter.endObject();
              }
              jsonWriter.endObject();
            }
          }
          jsonWriter.endArray();
        }
        jsonWriter.endObject();
      }

      com.amazonaws.internal.ListWithAutoConstructFlag<CreateJobOutput> outputsList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<CreateJobOutput>)
              (createJobRequest.getOutputs());
      if (outputsList != null && !(outputsList.isAutoConstruct() && outputsList.isEmpty())) {

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

        for (CreateJobOutput outputsListValue : outputsList) {
          if (outputsListValue != null) {
            jsonWriter.object();
            if (outputsListValue.getKey() != null) {
              jsonWriter.key("Key").value(outputsListValue.getKey());
            }
            if (outputsListValue.getThumbnailPattern() != null) {
              jsonWriter.key("ThumbnailPattern").value(outputsListValue.getThumbnailPattern());
            }
            if (outputsListValue.getRotate() != null) {
              jsonWriter.key("Rotate").value(outputsListValue.getRotate());
            }
            if (outputsListValue.getPresetId() != null) {
              jsonWriter.key("PresetId").value(outputsListValue.getPresetId());
            }
            if (outputsListValue.getSegmentDuration() != null) {
              jsonWriter.key("SegmentDuration").value(outputsListValue.getSegmentDuration());
            }

            com.amazonaws.internal.ListWithAutoConstructFlag<JobWatermark> watermarksList =
                (com.amazonaws.internal.ListWithAutoConstructFlag<JobWatermark>)
                    (outputsListValue.getWatermarks());
            if (watermarksList != null
                && !(watermarksList.isAutoConstruct() && watermarksList.isEmpty())) {

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

              for (JobWatermark watermarksListValue : watermarksList) {
                if (watermarksListValue != null) {
                  jsonWriter.object();
                  if (watermarksListValue.getPresetWatermarkId() != null) {
                    jsonWriter
                        .key("PresetWatermarkId")
                        .value(watermarksListValue.getPresetWatermarkId());
                  }
                  if (watermarksListValue.getInputKey() != null) {
                    jsonWriter.key("InputKey").value(watermarksListValue.getInputKey());
                  }
                  jsonWriter.endObject();
                }
              }
              jsonWriter.endArray();
            }
            JobAlbumArt albumArt = outputsListValue.getAlbumArt();
            if (albumArt != null) {

              jsonWriter.key("AlbumArt");
              jsonWriter.object();

              if (albumArt.getMergePolicy() != null) {
                jsonWriter.key("MergePolicy").value(albumArt.getMergePolicy());
              }

              com.amazonaws.internal.ListWithAutoConstructFlag<Artwork> artworkList =
                  (com.amazonaws.internal.ListWithAutoConstructFlag<Artwork>)
                      (albumArt.getArtwork());
              if (artworkList != null
                  && !(artworkList.isAutoConstruct() && artworkList.isEmpty())) {

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

                for (Artwork artworkListValue : artworkList) {
                  if (artworkListValue != null) {
                    jsonWriter.object();
                    if (artworkListValue.getInputKey() != null) {
                      jsonWriter.key("InputKey").value(artworkListValue.getInputKey());
                    }
                    if (artworkListValue.getMaxWidth() != null) {
                      jsonWriter.key("MaxWidth").value(artworkListValue.getMaxWidth());
                    }
                    if (artworkListValue.getMaxHeight() != null) {
                      jsonWriter.key("MaxHeight").value(artworkListValue.getMaxHeight());
                    }
                    if (artworkListValue.getSizingPolicy() != null) {
                      jsonWriter.key("SizingPolicy").value(artworkListValue.getSizingPolicy());
                    }
                    if (artworkListValue.getPaddingPolicy() != null) {
                      jsonWriter.key("PaddingPolicy").value(artworkListValue.getPaddingPolicy());
                    }
                    if (artworkListValue.getAlbumArtFormat() != null) {
                      jsonWriter.key("AlbumArtFormat").value(artworkListValue.getAlbumArtFormat());
                    }
                    jsonWriter.endObject();
                  }
                }
                jsonWriter.endArray();
              }
              jsonWriter.endObject();
            }

            com.amazonaws.internal.ListWithAutoConstructFlag<Clip> compositionList =
                (com.amazonaws.internal.ListWithAutoConstructFlag<Clip>)
                    (outputsListValue.getComposition());
            if (compositionList != null
                && !(compositionList.isAutoConstruct() && compositionList.isEmpty())) {

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

              for (Clip compositionListValue : compositionList) {
                if (compositionListValue != null) {
                  jsonWriter.object();
                  TimeSpan timeSpan = compositionListValue.getTimeSpan();
                  if (timeSpan != null) {

                    jsonWriter.key("TimeSpan");
                    jsonWriter.object();

                    if (timeSpan.getStartTime() != null) {
                      jsonWriter.key("StartTime").value(timeSpan.getStartTime());
                    }
                    if (timeSpan.getDuration() != null) {
                      jsonWriter.key("Duration").value(timeSpan.getDuration());
                    }
                    jsonWriter.endObject();
                  }
                  jsonWriter.endObject();
                }
              }
              jsonWriter.endArray();
            }
            jsonWriter.endObject();
          }
        }
        jsonWriter.endArray();
      }
      if (createJobRequest.getOutputKeyPrefix() != null) {
        jsonWriter.key("OutputKeyPrefix").value(createJobRequest.getOutputKeyPrefix());
      }

      com.amazonaws.internal.ListWithAutoConstructFlag<CreateJobPlaylist> playlistsList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<CreateJobPlaylist>)
              (createJobRequest.getPlaylists());
      if (playlistsList != null && !(playlistsList.isAutoConstruct() && playlistsList.isEmpty())) {

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

        for (CreateJobPlaylist playlistsListValue : playlistsList) {
          if (playlistsListValue != null) {
            jsonWriter.object();
            if (playlistsListValue.getName() != null) {
              jsonWriter.key("Name").value(playlistsListValue.getName());
            }
            if (playlistsListValue.getFormat() != null) {
              jsonWriter.key("Format").value(playlistsListValue.getFormat());
            }

            com.amazonaws.internal.ListWithAutoConstructFlag<String> outputKeysList =
                (com.amazonaws.internal.ListWithAutoConstructFlag<String>)
                    (playlistsListValue.getOutputKeys());
            if (outputKeysList != null
                && !(outputKeysList.isAutoConstruct() && outputKeysList.isEmpty())) {

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

              for (String outputKeysListValue : outputKeysList) {
                if (outputKeysListValue != null) {
                  jsonWriter.value(outputKeysListValue);
                }
              }
              jsonWriter.endArray();
            }
            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.0");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }