Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   * 
   *  http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.codedeploy.model.transform;
 
 import static com.amazonaws.util.StringUtils.UTF8;
 import static com.amazonaws.util.StringUtils.COMMA_SEPARATOR;
 import java.io.Writer;
 import java.util.Map;
 import java.util.List;
 
Update Deployment Group Request Marshaller
 
 
     public Request<UpdateDeploymentGroupRequestmarshall(UpdateDeploymentGroupRequest updateDeploymentGroupRequest) {
         if (updateDeploymentGroupRequest == null) {
             throw new AmazonClientException("Invalid argument passed to marshall(...)");
         }
 
         Request<UpdateDeploymentGroupRequestrequest = new DefaultRequest<UpdateDeploymentGroupRequest>(updateDeploymentGroupRequest"AmazonCodeDeploy");
         String target = "CodeDeploy_20141006.UpdateDeploymentGroup";
         request.addHeader("X-Amz-Target"target);
 
         request.setHttpMethod(.);
         request.setResourcePath("");
         
         try {
           StringWriter stringWriter = new StringWriter();
           JSONWriter jsonWriter = new JSONWriter(stringWriter);
 
           jsonWriter.object();
           
             if (updateDeploymentGroupRequest.getApplicationName() != null) {
                 jsonWriter.key("applicationName").value(updateDeploymentGroupRequest.getApplicationName());
             }
             if (updateDeploymentGroupRequest.getCurrentDeploymentGroupName() != null) {
                 jsonWriter.key("currentDeploymentGroupName").value(updateDeploymentGroupRequest.getCurrentDeploymentGroupName());
             }
             if (updateDeploymentGroupRequest.getNewDeploymentGroupName() != null) {
                 jsonWriter.key("newDeploymentGroupName").value(updateDeploymentGroupRequest.getNewDeploymentGroupName());
             }
             if (updateDeploymentGroupRequest.getDeploymentConfigName() != null) {
                 jsonWriter.key("deploymentConfigName").value(updateDeploymentGroupRequest.getDeploymentConfigName());
             }
 
             com.amazonaws.internal.ListWithAutoConstructFlag<EC2TagFilterec2TagFiltersList = (com.amazonaws.internal.ListWithAutoConstructFlag<EC2TagFilter>)(updateDeploymentGroupRequest.getEc2TagFilters());
             if (ec2TagFiltersList != null && !(ec2TagFiltersList.isAutoConstruct() && ec2TagFiltersList.isEmpty())) {
 
                 jsonWriter.key("ec2TagFilters");
                 jsonWriter.array();
 
                 for (EC2TagFilter ec2TagFiltersListValue : ec2TagFiltersList) {
                     if (ec2TagFiltersListValue != null) {
                         jsonWriter.object();
                         if (ec2TagFiltersListValue.getKey() != null) {
                             jsonWriter.key("Key").value(ec2TagFiltersListValue.getKey());
                         }
                         if (ec2TagFiltersListValue.getValue() != null) {
                             jsonWriter.key("Value").value(ec2TagFiltersListValue.getValue());
                         }
                         if (ec2TagFiltersListValue.getType() != null) {
                             jsonWriter.key("Type").value(ec2TagFiltersListValue.getType());
                         }
                         jsonWriter.endObject();
                     }
                 }
                 jsonWriter.endArray();
             }
            com.amazonaws.internal.ListWithAutoConstructFlag<TagFilteronPremisesInstanceTagFiltersList = (com.amazonaws.internal.ListWithAutoConstructFlag<TagFilter>)(updateDeploymentGroupRequest.getOnPremisesInstanceTagFilters());
            if (onPremisesInstanceTagFiltersList != null && !(onPremisesInstanceTagFiltersList.isAutoConstruct() && onPremisesInstanceTagFiltersList.isEmpty())) {
                jsonWriter.key("onPremisesInstanceTagFilters");
                jsonWriter.array();
                for (TagFilter onPremisesInstanceTagFiltersListValue : onPremisesInstanceTagFiltersList) {
                    if (onPremisesInstanceTagFiltersListValue != null) {
                        jsonWriter.object();
                        if (onPremisesInstanceTagFiltersListValue.getKey() != null) {
                            jsonWriter.key("Key").value(onPremisesInstanceTagFiltersListValue.getKey());
                        }
                        if (onPremisesInstanceTagFiltersListValue.getValue() != null) {
                            jsonWriter.key("Value").value(onPremisesInstanceTagFiltersListValue.getValue());
                        }
                        if (onPremisesInstanceTagFiltersListValue.getType() != null) {
                            jsonWriter.key("Type").value(onPremisesInstanceTagFiltersListValue.getType());
                        }
                        jsonWriter.endObject();
                    }
                }
                jsonWriter.endArray();
            }
            com.amazonaws.internal.ListWithAutoConstructFlag<StringautoScalingGroupsList = (com.amazonaws.internal.ListWithAutoConstructFlag<String>)(updateDeploymentGroupRequest.getAutoScalingGroups());
            if (autoScalingGroupsList != null && !(autoScalingGroupsList.isAutoConstruct() && autoScalingGroupsList.isEmpty())) {
                jsonWriter.key("autoScalingGroups");
                jsonWriter.array();
                for (String autoScalingGroupsListValue : autoScalingGroupsList) {
                    if (autoScalingGroupsListValue != null) {
                        jsonWriter.value(autoScalingGroupsListValue);
                    }
                }
                jsonWriter.endArray();
            }
            if (updateDeploymentGroupRequest.getServiceRoleArn() != null) {
                jsonWriter.key("serviceRoleArn").value(updateDeploymentGroupRequest.getServiceRoleArn());
            }
          jsonWriter.endObject();
          String snippet = stringWriter.toString();
          byte[] content = snippet.getBytes();
          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;
    }
New to GrepCode? Check out our FAQ X