/** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(PipelineContext pipelineContext, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (pipelineContext.getPipelineName() != null) {
        jsonGenerator.writeFieldName("pipelineName").writeValue(pipelineContext.getPipelineName());
      }
      if (pipelineContext.getStage() != null) {
        jsonGenerator.writeFieldName("stage");
        StageContextJsonMarshaller.getInstance()
            .marshall(pipelineContext.getStage(), jsonGenerator);
      }
      if (pipelineContext.getAction() != null) {
        jsonGenerator.writeFieldName("action");
        ActionContextJsonMarshaller.getInstance()
            .marshall(pipelineContext.getAction(), jsonGenerator);
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
Ejemplo n.º 2
0
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(StepConfig stepConfig, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (stepConfig.getName() != null) {
        jsonGenerator.writeFieldName("Name").writeValue(stepConfig.getName());
      }
      if (stepConfig.getActionOnFailure() != null) {
        jsonGenerator.writeFieldName("ActionOnFailure").writeValue(stepConfig.getActionOnFailure());
      }
      if (stepConfig.getHadoopJarStep() != null) {
        jsonGenerator.writeFieldName("HadoopJarStep");
        HadoopJarStepConfigJsonMarshaller.getInstance()
            .marshall(stepConfig.getHadoopJarStep(), jsonGenerator);
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      EventDetailsErrorItem eventDetailsErrorItem, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (eventDetailsErrorItem.getEventArn() != null) {
        jsonGenerator.writeFieldName("eventArn").writeValue(eventDetailsErrorItem.getEventArn());
      }
      if (eventDetailsErrorItem.getErrorName() != null) {
        jsonGenerator.writeFieldName("errorName").writeValue(eventDetailsErrorItem.getErrorName());
      }
      if (eventDetailsErrorItem.getErrorMessage() != null) {
        jsonGenerator
            .writeFieldName("errorMessage")
            .writeValue(eventDetailsErrorItem.getErrorMessage());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      FailWorkflowExecutionFailedEventAttributes failWorkflowExecutionFailedEventAttributes,
      StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (failWorkflowExecutionFailedEventAttributes.getCause() != null) {
        jsonGenerator
            .writeFieldName("cause")
            .writeValue(failWorkflowExecutionFailedEventAttributes.getCause());
      }
      if (failWorkflowExecutionFailedEventAttributes.getDecisionTaskCompletedEventId() != null) {
        jsonGenerator
            .writeFieldName("decisionTaskCompletedEventId")
            .writeValue(
                failWorkflowExecutionFailedEventAttributes.getDecisionTaskCompletedEventId());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
 @Test
 public void unclosedObject_AutoClosesOnClose() throws IOException {
   jsonGenerator.writeStartObject();
   jsonGenerator.writeFieldName("stringProp").writeValue("stringVal");
   JsonNode node = toJsonNode();
   assertTrue(node.isObject());
 }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      RejectedLogEventsInfo rejectedLogEventsInfo, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (rejectedLogEventsInfo.getTooNewLogEventStartIndex() != null) {
        jsonGenerator
            .writeFieldName("tooNewLogEventStartIndex")
            .writeValue(rejectedLogEventsInfo.getTooNewLogEventStartIndex());
      }
      if (rejectedLogEventsInfo.getTooOldLogEventEndIndex() != null) {
        jsonGenerator
            .writeFieldName("tooOldLogEventEndIndex")
            .writeValue(rejectedLogEventsInfo.getTooOldLogEventEndIndex());
      }
      if (rejectedLogEventsInfo.getExpiredLogEventEndIndex() != null) {
        jsonGenerator
            .writeFieldName("expiredLogEventEndIndex")
            .writeValue(rejectedLogEventsInfo.getExpiredLogEventEndIndex());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<DescribeAccountAttributesRequest> marshall(
      DescribeAccountAttributesRequest describeAccountAttributesRequest) {

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

    Request<DescribeAccountAttributesRequest> request =
        new DefaultRequest<DescribeAccountAttributesRequest>(
            describeAccountAttributesRequest, "AWSOpsWorksCM");
    request.addHeader("X-Amz-Target", "OpsWorksCM_V2016_11_01.DescribeAccountAttributes");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(JobWatermark jobWatermark, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (jobWatermark.getPresetWatermarkId() != null) {
        jsonGenerator
            .writeFieldName("PresetWatermarkId")
            .writeValue(jobWatermark.getPresetWatermarkId());
      }
      if (jobWatermark.getInputKey() != null) {
        jsonGenerator.writeFieldName("InputKey").writeValue(jobWatermark.getInputKey());
      }
      if (jobWatermark.getEncryption() != null) {
        jsonGenerator.writeFieldName("Encryption");
        EncryptionJsonMarshaller.getInstance()
            .marshall(jobWatermark.getEncryption(), jsonGenerator);
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      CodeDeliveryDetailsType codeDeliveryDetailsType, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (codeDeliveryDetailsType.getDestination() != null) {
        jsonGenerator
            .writeFieldName("Destination")
            .writeValue(codeDeliveryDetailsType.getDestination());
      }
      if (codeDeliveryDetailsType.getDeliveryMedium() != null) {
        jsonGenerator
            .writeFieldName("DeliveryMedium")
            .writeValue(codeDeliveryDetailsType.getDeliveryMedium());
      }
      if (codeDeliveryDetailsType.getAttributeName() != null) {
        jsonGenerator
            .writeFieldName("AttributeName")
            .writeValue(codeDeliveryDetailsType.getAttributeName());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(LoadBalancer loadBalancer, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (loadBalancer.getLoadBalancerName() != null) {
        jsonGenerator
            .writeFieldName("loadBalancerName")
            .writeValue(loadBalancer.getLoadBalancerName());
      }
      if (loadBalancer.getContainerName() != null) {
        jsonGenerator.writeFieldName("containerName").writeValue(loadBalancer.getContainerName());
      }
      if (loadBalancer.getContainerPort() != null) {
        jsonGenerator.writeFieldName("containerPort").writeValue(loadBalancer.getContainerPort());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      CloudWatchLoggingOptions cloudWatchLoggingOptions, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (cloudWatchLoggingOptions.getEnabled() != null) {
        jsonGenerator.writeFieldName("Enabled").writeValue(cloudWatchLoggingOptions.getEnabled());
      }
      if (cloudWatchLoggingOptions.getLogGroupName() != null) {
        jsonGenerator
            .writeFieldName("LogGroupName")
            .writeValue(cloudWatchLoggingOptions.getLogGroupName());
      }
      if (cloudWatchLoggingOptions.getLogStreamName() != null) {
        jsonGenerator
            .writeFieldName("LogStreamName")
            .writeValue(cloudWatchLoggingOptions.getLogStreamName());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<DeletePipelineRequest> marshall(DeletePipelineRequest deletePipelineRequest) {

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

    Request<DeletePipelineRequest> request =
        new DefaultRequest<DeletePipelineRequest>(deletePipelineRequest, "AWSCodePipeline");
    request.addHeader("X-Amz-Target", "CodePipeline_20150709.DeletePipeline");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (deletePipelineRequest.getName() != null) {
        jsonGenerator.writeFieldName("name").writeValue(deletePipelineRequest.getName());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(TaskOverride taskOverride, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      com.amazonaws.internal.SdkInternalList<ContainerOverride> containerOverridesList =
          (com.amazonaws.internal.SdkInternalList<ContainerOverride>)
              taskOverride.getContainerOverrides();
      if (!containerOverridesList.isEmpty() || !containerOverridesList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("containerOverrides");
        jsonGenerator.writeStartArray();
        for (ContainerOverride containerOverridesListValue : containerOverridesList) {
          if (containerOverridesListValue != null) {

            ContainerOverrideJsonMarshaller.getInstance()
                .marshall(containerOverridesListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      UpdateProvisioningParameter updateProvisioningParameter,
      StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (updateProvisioningParameter.getKey() != null) {
        jsonGenerator.writeFieldName("Key").writeValue(updateProvisioningParameter.getKey());
      }
      if (updateProvisioningParameter.getValue() != null) {
        jsonGenerator.writeFieldName("Value").writeValue(updateProvisioningParameter.getValue());
      }
      if (updateProvisioningParameter.getUsePreviousValue() != null) {
        jsonGenerator
            .writeFieldName("UsePreviousValue")
            .writeValue(updateProvisioningParameter.getUsePreviousValue());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(PolicyVersion policyVersion, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (policyVersion.getVersionId() != null) {
        jsonGenerator.writeFieldName("versionId").writeValue(policyVersion.getVersionId());
      }
      if (policyVersion.getIsDefaultVersion() != null) {
        jsonGenerator
            .writeFieldName("isDefaultVersion")
            .writeValue(policyVersion.getIsDefaultVersion());
      }
      if (policyVersion.getCreateDate() != null) {
        jsonGenerator.writeFieldName("createDate").writeValue(policyVersion.getCreateDate());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<CancelJobRequest> marshall(CancelJobRequest cancelJobRequest) {

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

    Request<CancelJobRequest> request =
        new DefaultRequest<CancelJobRequest>(cancelJobRequest, "AmazonSnowball");
    request.addHeader("X-Amz-Target", "AWSIESnowballJobManagementService.CancelJob");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (cancelJobRequest.getJobId() != null) {
        jsonGenerator.writeFieldName("JobId").writeValue(cancelJobRequest.getJobId());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
 @Test
 public void simpleObject_WithLongProperty_PreservesLongValue() throws IOException {
   jsonGenerator.writeStartObject();
   jsonGenerator.writeFieldName("longProp").writeValue(Long.MAX_VALUE);
   jsonGenerator.writeEndObject();
   JsonNode node = toJsonNode();
   assertEquals(Long.MAX_VALUE, node.get("longProp").longValue());
 }
 @Test
 public void simpleObject_WithServiceDate() throws IOException {
   Date date = new Date(123456);
   jsonGenerator.writeStartObject();
   jsonGenerator.writeFieldName("dateProp").writeValue(date);
   jsonGenerator.writeEndObject();
   JsonNode node = toJsonNode();
   assertEquals(123.456, node.get("dateProp").doubleValue(), DELTA);
 }
 @Test
 public void simpleObject_WithBinaryData_WritesAsBase64() throws IOException {
   byte[] data = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
   jsonGenerator.writeStartObject();
   jsonGenerator.writeFieldName("binaryProp").writeValue(ByteBuffer.wrap(data));
   jsonGenerator.writeEndObject();
   JsonNode node = toJsonNode();
   assertEquals(Base64.encodeAsString(data), node.get("binaryProp").textValue());
 }
 @Test
 public void complexArray() throws IOException {
   jsonGenerator.writeStartArray();
   jsonGenerator.writeStartObject();
   jsonGenerator.writeFieldName("nestedProp").writeValue("nestedVal");
   jsonGenerator.writeEndObject();
   jsonGenerator.writeEndArray();
   JsonNode node = toJsonNode();
   assertEquals("nestedVal", node.get(0).get("nestedProp").textValue());
 }
 @Test
 public void unclosedArray_AutoClosesOnClose() throws IOException {
   jsonGenerator.writeStartArray();
   jsonGenerator.writeValue("valOne");
   jsonGenerator.writeValue("valTwo");
   jsonGenerator.writeValue("valThree");
   JsonNode node = toJsonNode();
   assertTrue(node.isArray());
   assertEquals(3, node.size());
 }
  public Request<DescribeRaidArraysRequest> marshall(
      DescribeRaidArraysRequest describeRaidArraysRequest) {

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

    Request<DescribeRaidArraysRequest> request =
        new DefaultRequest<DescribeRaidArraysRequest>(describeRaidArraysRequest, "AWSOpsWorks");
    request.addHeader("X-Amz-Target", "OpsWorks_20130218.DescribeRaidArrays");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (describeRaidArraysRequest.getInstanceId() != null) {
        jsonGenerator
            .writeFieldName("InstanceId")
            .writeValue(describeRaidArraysRequest.getInstanceId());
      }
      if (describeRaidArraysRequest.getStackId() != null) {
        jsonGenerator.writeFieldName("StackId").writeValue(describeRaidArraysRequest.getStackId());
      }

      com.amazonaws.internal.SdkInternalList<String> raidArrayIdsList =
          (com.amazonaws.internal.SdkInternalList<String>)
              describeRaidArraysRequest.getRaidArrayIds();
      if (!raidArrayIdsList.isEmpty() || !raidArrayIdsList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("RaidArrayIds");
        jsonGenerator.writeStartArray();
        for (String raidArrayIdsListValue : raidArrayIdsList) {
          if (raidArrayIdsListValue != null) {
            jsonGenerator.writeValue(raidArrayIdsListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<ListOnPremisesInstancesRequest> marshall(
      ListOnPremisesInstancesRequest listOnPremisesInstancesRequest) {

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

    Request<ListOnPremisesInstancesRequest> request =
        new DefaultRequest<ListOnPremisesInstancesRequest>(
            listOnPremisesInstancesRequest, "AmazonCodeDeploy");
    request.addHeader("X-Amz-Target", "CodeDeploy_20141006.ListOnPremisesInstances");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (listOnPremisesInstancesRequest.getRegistrationStatus() != null) {
        jsonGenerator
            .writeFieldName("registrationStatus")
            .writeValue(listOnPremisesInstancesRequest.getRegistrationStatus());
      }

      com.amazonaws.internal.SdkInternalList<TagFilter> tagFiltersList =
          (com.amazonaws.internal.SdkInternalList<TagFilter>)
              listOnPremisesInstancesRequest.getTagFilters();
      if (!tagFiltersList.isEmpty() || !tagFiltersList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("tagFilters");
        jsonGenerator.writeStartArray();
        for (TagFilter tagFiltersListValue : tagFiltersList) {
          if (tagFiltersListValue != null) {

            TagFilterJsonMarshaller.getInstance().marshall(tagFiltersListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (listOnPremisesInstancesRequest.getNextToken() != null) {
        jsonGenerator
            .writeFieldName("nextToken")
            .writeValue(listOnPremisesInstancesRequest.getNextToken());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<TerminateProvisionedProductRequest> marshall(
      TerminateProvisionedProductRequest terminateProvisionedProductRequest) {

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

    Request<TerminateProvisionedProductRequest> request =
        new DefaultRequest<TerminateProvisionedProductRequest>(
            terminateProvisionedProductRequest, "AWSServiceCatalog");
    request.addHeader("X-Amz-Target", "AWS242ServiceCatalogService.TerminateProvisionedProduct");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (terminateProvisionedProductRequest.getProvisionedProductName() != null) {
        jsonGenerator
            .writeFieldName("ProvisionedProductName")
            .writeValue(terminateProvisionedProductRequest.getProvisionedProductName());
      }
      if (terminateProvisionedProductRequest.getProvisionedProductId() != null) {
        jsonGenerator
            .writeFieldName("ProvisionedProductId")
            .writeValue(terminateProvisionedProductRequest.getProvisionedProductId());
      }
      jsonGenerator
          .writeFieldName("TerminateToken")
          .writeValue(
              IdempotentUtils.resolveString(
                  terminateProvisionedProductRequest.getTerminateToken()));
      if (terminateProvisionedProductRequest.getIgnoreErrors() != null) {
        jsonGenerator
            .writeFieldName("IgnoreErrors")
            .writeValue(terminateProvisionedProductRequest.getIgnoreErrors());
      }
      if (terminateProvisionedProductRequest.getAcceptLanguage() != null) {
        jsonGenerator
            .writeFieldName("AcceptLanguage")
            .writeValue(terminateProvisionedProductRequest.getAcceptLanguage());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<RespondDecisionTaskCompletedRequest> marshall(
      RespondDecisionTaskCompletedRequest respondDecisionTaskCompletedRequest) {

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

    Request<RespondDecisionTaskCompletedRequest> request =
        new DefaultRequest<RespondDecisionTaskCompletedRequest>(
            respondDecisionTaskCompletedRequest, "AmazonSimpleWorkflow");
    request.addHeader("X-Amz-Target", "SimpleWorkflowService.RespondDecisionTaskCompleted");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (respondDecisionTaskCompletedRequest.getTaskToken() != null) {
        jsonGenerator
            .writeFieldName("taskToken")
            .writeValue(respondDecisionTaskCompletedRequest.getTaskToken());
      }

      java.util.List<Decision> decisionsList = respondDecisionTaskCompletedRequest.getDecisions();
      if (decisionsList != null) {
        jsonGenerator.writeFieldName("decisions");
        jsonGenerator.writeStartArray();
        for (Decision decisionsListValue : decisionsList) {
          if (decisionsListValue != null) {

            DecisionJsonMarshaller.getInstance().marshall(decisionsListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (respondDecisionTaskCompletedRequest.getExecutionContext() != null) {
        jsonGenerator
            .writeFieldName("executionContext")
            .writeValue(respondDecisionTaskCompletedRequest.getExecutionContext());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<UpdateByteMatchSetRequest> marshall(
      UpdateByteMatchSetRequest updateByteMatchSetRequest) {

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

    Request<UpdateByteMatchSetRequest> request =
        new DefaultRequest<UpdateByteMatchSetRequest>(updateByteMatchSetRequest, "AWSWAF");
    request.addHeader("X-Amz-Target", "AWSWAF_20150824.UpdateByteMatchSet");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (updateByteMatchSetRequest.getByteMatchSetId() != null) {
        jsonGenerator
            .writeFieldName("ByteMatchSetId")
            .writeValue(updateByteMatchSetRequest.getByteMatchSetId());
      }
      if (updateByteMatchSetRequest.getChangeToken() != null) {
        jsonGenerator
            .writeFieldName("ChangeToken")
            .writeValue(updateByteMatchSetRequest.getChangeToken());
      }

      java.util.List<ByteMatchSetUpdate> updatesList = updateByteMatchSetRequest.getUpdates();
      if (updatesList != null) {
        jsonGenerator.writeFieldName("Updates");
        jsonGenerator.writeStartArray();
        for (ByteMatchSetUpdate updatesListValue : updatesList) {
          if (updatesListValue != null) {

            ByteMatchSetUpdateJsonMarshaller.getInstance()
                .marshall(updatesListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
 @Test
 public void stringArray() throws IOException {
   jsonGenerator.writeStartArray();
   jsonGenerator.writeValue("valOne");
   jsonGenerator.writeValue("valTwo");
   jsonGenerator.writeValue("valThree");
   jsonGenerator.writeEndArray();
   JsonNode node = toJsonNode();
   assertTrue(node.isArray());
   assertEquals("valOne", node.get(0).textValue());
   assertEquals("valTwo", node.get(1).textValue());
   assertEquals("valThree", node.get(2).textValue());
 }
  public Request<ListDocumentsRequest> marshall(ListDocumentsRequest listDocumentsRequest) {

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

    Request<ListDocumentsRequest> request =
        new DefaultRequest<ListDocumentsRequest>(
            listDocumentsRequest, "AWSSimpleSystemsManagement");
    request.addHeader("X-Amz-Target", "AmazonSSM.ListDocuments");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      com.amazonaws.internal.SdkInternalList<DocumentFilter> documentFilterListList =
          (com.amazonaws.internal.SdkInternalList<DocumentFilter>)
              listDocumentsRequest.getDocumentFilterList();
      if (!documentFilterListList.isEmpty() || !documentFilterListList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("DocumentFilterList");
        jsonGenerator.writeStartArray();
        for (DocumentFilter documentFilterListListValue : documentFilterListList) {
          if (documentFilterListListValue != null) {

            DocumentFilterJsonMarshaller.getInstance()
                .marshall(documentFilterListListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (listDocumentsRequest.getMaxResults() != null) {
        jsonGenerator.writeFieldName("MaxResults").writeValue(listDocumentsRequest.getMaxResults());
      }
      if (listDocumentsRequest.getNextToken() != null) {
        jsonGenerator.writeFieldName("NextToken").writeValue(listDocumentsRequest.getNextToken());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<AddInstanceGroupsRequest> marshall(
      AddInstanceGroupsRequest addInstanceGroupsRequest) {

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

    Request<AddInstanceGroupsRequest> request =
        new DefaultRequest<AddInstanceGroupsRequest>(
            addInstanceGroupsRequest, "AmazonElasticMapReduce");
    request.addHeader("X-Amz-Target", "ElasticMapReduce.AddInstanceGroups");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      com.amazonaws.internal.SdkInternalList<InstanceGroupConfig> instanceGroupsList =
          (com.amazonaws.internal.SdkInternalList<InstanceGroupConfig>)
              addInstanceGroupsRequest.getInstanceGroups();
      if (!instanceGroupsList.isEmpty() || !instanceGroupsList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("InstanceGroups");
        jsonGenerator.writeStartArray();
        for (InstanceGroupConfig instanceGroupsListValue : instanceGroupsList) {
          if (instanceGroupsListValue != null) {

            InstanceGroupConfigJsonMarshaller.getInstance()
                .marshall(instanceGroupsListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (addInstanceGroupsRequest.getJobFlowId() != null) {
        jsonGenerator
            .writeFieldName("JobFlowId")
            .writeValue(addInstanceGroupsRequest.getJobFlowId());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", jsonGenerator.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<UpdateServiceRequest> marshall(UpdateServiceRequest updateServiceRequest) {

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

    Request<UpdateServiceRequest> request =
        new DefaultRequest<UpdateServiceRequest>(updateServiceRequest, "AmazonECS");
    request.addHeader("X-Amz-Target", "AmazonEC2ContainerServiceV20141113.UpdateService");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (updateServiceRequest.getCluster() != null) {
        jsonGenerator.writeFieldName("cluster").writeValue(updateServiceRequest.getCluster());
      }
      if (updateServiceRequest.getService() != null) {
        jsonGenerator.writeFieldName("service").writeValue(updateServiceRequest.getService());
      }
      if (updateServiceRequest.getDesiredCount() != null) {
        jsonGenerator
            .writeFieldName("desiredCount")
            .writeValue(updateServiceRequest.getDesiredCount());
      }
      if (updateServiceRequest.getTaskDefinition() != null) {
        jsonGenerator
            .writeFieldName("taskDefinition")
            .writeValue(updateServiceRequest.getTaskDefinition());
      }
      if (updateServiceRequest.getDeploymentConfiguration() != null) {
        jsonGenerator.writeFieldName("deploymentConfiguration");
        DeploymentConfigurationJsonMarshaller.getInstance()
            .marshall(updateServiceRequest.getDeploymentConfiguration(), jsonGenerator);
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }