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

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

    try {
      jsonGenerator.writeStartObject();

      if (s3Location.getBucket() != null) {
        jsonGenerator.writeFieldName("bucket").writeValue(s3Location.getBucket());
      }
      if (s3Location.getKey() != null) {
        jsonGenerator.writeFieldName("key").writeValue(s3Location.getKey());
      }
      if (s3Location.getBundleType() != null) {
        jsonGenerator.writeFieldName("bundleType").writeValue(s3Location.getBundleType());
      }
      if (s3Location.getVersion() != null) {
        jsonGenerator.writeFieldName("version").writeValue(s3Location.getVersion());
      }
      if (s3Location.getETag() != null) {
        jsonGenerator.writeFieldName("eTag").writeValue(s3Location.getETag());
      }

      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 JSONWriter */
  public void marshall(EC2TagFilter eC2TagFilter, JSONWriter jsonWriter) {
    if (eC2TagFilter == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

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

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

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

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

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

    Request<RegisterOnPremisesInstanceRequest> request =
        new DefaultRequest<RegisterOnPremisesInstanceRequest>(
            registerOnPremisesInstanceRequest, "AmazonCodeDeploy");
    request.addHeader("X-Amz-Target", "CodeDeploy_20141006.RegisterOnPremisesInstance");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (registerOnPremisesInstanceRequest.getInstanceName() != null) {
        jsonGenerator
            .writeFieldName("instanceName")
            .writeValue(registerOnPremisesInstanceRequest.getInstanceName());
      }
      if (registerOnPremisesInstanceRequest.getIamUserArn() != null) {
        jsonGenerator
            .writeFieldName("iamUserArn")
            .writeValue(registerOnPremisesInstanceRequest.getIamUserArn());
      }

      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<DeleteDeploymentConfigRequest> marshall(
      DeleteDeploymentConfigRequest deleteDeploymentConfigRequest) {

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

    Request<DeleteDeploymentConfigRequest> request =
        new DefaultRequest<DeleteDeploymentConfigRequest>(
            deleteDeploymentConfigRequest, "AmazonCodeDeploy");
    request.addHeader("X-Amz-Target", "CodeDeploy_20141006.DeleteDeploymentConfig");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonWriter.object();

      if (deleteDeploymentConfigRequest.getDeploymentConfigName() != null) {
        jsonWriter
            .key("deploymentConfigName")
            .value(deleteDeploymentConfigRequest.getDeploymentConfigName());
      }

      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;
  }