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

    Request<ListTaskDefinitionFamiliesRequest> request =
        new DefaultRequest<ListTaskDefinitionFamiliesRequest>(
            listTaskDefinitionFamiliesRequest, "AmazonECS");
    String target = "AmazonEC2ContainerServiceV20141113.ListTaskDefinitionFamilies";
    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 (listTaskDefinitionFamiliesRequest.getFamilyPrefix() != null) {
        jsonWriter.key("familyPrefix").value(listTaskDefinitionFamiliesRequest.getFamilyPrefix());
      }
      if (listTaskDefinitionFamiliesRequest.getNextToken() != null) {
        jsonWriter.key("nextToken").value(listTaskDefinitionFamiliesRequest.getNextToken());
      }
      if (listTaskDefinitionFamiliesRequest.getMaxResults() != null) {
        jsonWriter.key("maxResults").value(listTaskDefinitionFamiliesRequest.getMaxResults());
      }

      jsonWriter.endObject();

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

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

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

    try {
      jsonGenerator.writeStartObject();

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

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