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

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

    try {
      jsonGenerator.writeStartObject();

      if (parameterObject.getId() != null) {
        jsonGenerator.writeFieldName("id").writeValue(parameterObject.getId());
      }

      com.amazonaws.internal.SdkInternalList<ParameterAttribute> attributesList =
          (com.amazonaws.internal.SdkInternalList<ParameterAttribute>)
              parameterObject.getAttributes();
      if (!attributesList.isEmpty() || !attributesList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("attributes");
        jsonGenerator.writeStartArray();
        for (ParameterAttribute attributesListValue : attributesList) {
          if (attributesListValue != null) {

            ParameterAttributeJsonMarshaller.getInstance()
                .marshall(attributesListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

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

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

    Request<SetTaskStatusRequest> request =
        new DefaultRequest<SetTaskStatusRequest>(setTaskStatusRequest, "DataPipeline");
    request.addHeader("X-Amz-Target", "DataPipeline.SetTaskStatus");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (setTaskStatusRequest.getTaskId() != null) {
        jsonGenerator.writeFieldName("taskId").writeValue(setTaskStatusRequest.getTaskId());
      }
      if (setTaskStatusRequest.getTaskStatus() != null) {
        jsonGenerator.writeFieldName("taskStatus").writeValue(setTaskStatusRequest.getTaskStatus());
      }
      if (setTaskStatusRequest.getErrorId() != null) {
        jsonGenerator.writeFieldName("errorId").writeValue(setTaskStatusRequest.getErrorId());
      }
      if (setTaskStatusRequest.getErrorMessage() != null) {
        jsonGenerator
            .writeFieldName("errorMessage")
            .writeValue(setTaskStatusRequest.getErrorMessage());
      }
      if (setTaskStatusRequest.getErrorStackTrace() != null) {
        jsonGenerator
            .writeFieldName("errorStackTrace")
            .writeValue(setTaskStatusRequest.getErrorStackTrace());
      }

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

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

    Request<DescribePipelinesRequest> request =
        new DefaultRequest<DescribePipelinesRequest>(describePipelinesRequest, "DataPipeline");
    request.addHeader("X-Amz-Target", "DataPipeline.DescribePipelines");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      com.amazonaws.internal.SdkInternalList<String> pipelineIdsList =
          (com.amazonaws.internal.SdkInternalList<String>)
              describePipelinesRequest.getPipelineIds();
      if (!pipelineIdsList.isEmpty() || !pipelineIdsList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("pipelineIds");
        jsonGenerator.writeStartArray();
        for (String pipelineIdsListValue : pipelineIdsList) {
          if (pipelineIdsListValue != null) {
            jsonGenerator.writeValue(pipelineIdsListValue);
          }
        }
        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<CreatePipelineRequest> marshall(CreatePipelineRequest createPipelineRequest) {
    if (createPipelineRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreatePipelineRequest> request =
        new DefaultRequest<CreatePipelineRequest>(createPipelineRequest, "DataPipeline");
    String target = "DataPipeline.CreatePipeline";
    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 (createPipelineRequest.getName() != null) {
        jsonWriter.key("name").value(createPipelineRequest.getName());
      }
      if (createPipelineRequest.getUniqueId() != null) {
        jsonWriter.key("uniqueId").value(createPipelineRequest.getUniqueId());
      }
      if (createPipelineRequest.getDescription() != null) {
        jsonWriter.key("description").value(createPipelineRequest.getDescription());
      }

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

    try {
      jsonWriter.object();

      if (instanceIdentity.getDocument() != null) {
        jsonWriter.key("document").value(instanceIdentity.getDocument());
      }

      if (instanceIdentity.getSignature() != null) {
        jsonWriter.key("signature").value(instanceIdentity.getSignature());
      }

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

    Request<PollForTaskRequest> request =
        new DefaultRequest<PollForTaskRequest>(pollForTaskRequest, "DataPipeline");
    String target = "DataPipeline.PollForTask";
    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 (pollForTaskRequest.getWorkerGroup() != null) {
        jsonWriter.key("workerGroup").value(pollForTaskRequest.getWorkerGroup());
      }
      if (pollForTaskRequest.getHostname() != null) {
        jsonWriter.key("hostname").value(pollForTaskRequest.getHostname());
      }
      InstanceIdentity instanceIdentity = pollForTaskRequest.getInstanceIdentity();
      if (instanceIdentity != null) {

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

        if (instanceIdentity.getDocument() != null) {
          jsonWriter.key("document").value(instanceIdentity.getDocument());
        }
        if (instanceIdentity.getSignature() != null) {
          jsonWriter.key("signature").value(instanceIdentity.getSignature());
        }
        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;
  }