/** 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(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);
    }
  }
  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 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);
    }
  }