/**
  * This method is intended for internal use only. Returns the marshaled request configured with
  * additional parameters to enable operation dry-run.
  */
 @Override
 public Request<AuthorizeSecurityGroupEgressRequest> getDryRunRequest() {
   Request<AuthorizeSecurityGroupEgressRequest> request =
       new AuthorizeSecurityGroupEgressRequestMarshaller().marshall(this);
   request.addParameter("DryRun", Boolean.toString(true));
   return request;
 }
  public Request<DeleteScheduledActionRequest> marshall(
      DeleteScheduledActionRequest deleteScheduledActionRequest) {

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

    Request<DeleteScheduledActionRequest> request =
        new DefaultRequest<DeleteScheduledActionRequest>(
            deleteScheduledActionRequest, "AmazonAutoScaling");
    request.addParameter("Action", "DeleteScheduledAction");
    request.addParameter("Version", "2011-01-01");

    if (deleteScheduledActionRequest.getAutoScalingGroupName() != null) {
      request.addParameter(
          "AutoScalingGroupName",
          StringUtils.fromString(deleteScheduledActionRequest.getAutoScalingGroupName()));
    }
    if (deleteScheduledActionRequest.getScheduledActionName() != null) {
      request.addParameter(
          "ScheduledActionName",
          StringUtils.fromString(deleteScheduledActionRequest.getScheduledActionName()));
    }

    return request;
  }
  public Request<GetCloudFrontOriginAccessIdentityConfigRequest> marshall(
      GetCloudFrontOriginAccessIdentityConfigRequest
          getCloudFrontOriginAccessIdentityConfigRequest) {
    if (getCloudFrontOriginAccessIdentityConfigRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<GetCloudFrontOriginAccessIdentityConfigRequest> request =
        new DefaultRequest<GetCloudFrontOriginAccessIdentityConfigRequest>(
            getCloudFrontOriginAccessIdentityConfigRequest, "AmazonCloudFront");
    request.setHttpMethod(HttpMethodName.GET);

    String uriResourcePath = "2012-03-15/origin-access-identity/cloudfront/{Id}/config";
    uriResourcePath =
        uriResourcePath.replace(
            "{Id}", getString(getCloudFrontOriginAccessIdentityConfigRequest.getId()));

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

    return request;
  }
  public Request<CancelSpotInstanceRequestsRequest> marshall(
      CancelSpotInstanceRequestsRequest cancelSpotInstanceRequestsRequest) {

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

    Request<CancelSpotInstanceRequestsRequest> request =
        new DefaultRequest<CancelSpotInstanceRequestsRequest>(
            cancelSpotInstanceRequestsRequest, "AmazonEC2");
    request.addParameter("Action", "CancelSpotInstanceRequests");
    request.addParameter("Version", "2014-06-15");

    java.util.List<String> spotInstanceRequestIdsList =
        cancelSpotInstanceRequestsRequest.getSpotInstanceRequestIds();
    int spotInstanceRequestIdsListIndex = 1;

    for (String spotInstanceRequestIdsListValue : spotInstanceRequestIdsList) {
      if (spotInstanceRequestIdsListValue != null) {
        request.addParameter(
            "SpotInstanceRequestId." + spotInstanceRequestIdsListIndex,
            StringUtils.fromString(spotInstanceRequestIdsListValue));
      }

      spotInstanceRequestIdsListIndex++;
    }

    return request;
  }
  public Request<DeleteConfigurationTemplateRequest> marshall(
      DeleteConfigurationTemplateRequest deleteConfigurationTemplateRequest) {

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

    Request<DeleteConfigurationTemplateRequest> request =
        new DefaultRequest<DeleteConfigurationTemplateRequest>(
            deleteConfigurationTemplateRequest, "AWSElasticBeanstalk");
    request.addParameter("Action", "DeleteConfigurationTemplate");
    request.addParameter("Version", "2010-12-01");

    if (deleteConfigurationTemplateRequest.getApplicationName() != null) {
      request.addParameter(
          "ApplicationName",
          StringUtils.fromString(deleteConfigurationTemplateRequest.getApplicationName()));
    }
    if (deleteConfigurationTemplateRequest.getTemplateName() != null) {
      request.addParameter(
          "TemplateName",
          StringUtils.fromString(deleteConfigurationTemplateRequest.getTemplateName()));
    }

    return request;
  }
  public Request<EnableVolumeIORequest> marshall(EnableVolumeIORequest enableVolumeIORequest) {

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

    Request<EnableVolumeIORequest> request =
        new DefaultRequest<EnableVolumeIORequest>(enableVolumeIORequest, "AmazonEC2");
    request.addParameter("Action", "EnableVolumeIO");
    request.addParameter("Version", "2014-06-15");

    if (enableVolumeIORequest.getVolumeId() != null) {
      request.addParameter("VolumeId", StringUtils.fromString(enableVolumeIORequest.getVolumeId()));
    }

    return request;
  }
  public Request<CancelExportTaskRequest> marshall(
      CancelExportTaskRequest cancelExportTaskRequest) {

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

    Request<CancelExportTaskRequest> request =
        new DefaultRequest<CancelExportTaskRequest>(cancelExportTaskRequest, "AmazonEC2");
    request.addParameter("Action", "CancelExportTask");
    request.addParameter("Version", "2014-06-15");

    if (cancelExportTaskRequest.getExportTaskId() != null) {
      request.addParameter(
          "ExportTaskId", StringUtils.fromString(cancelExportTaskRequest.getExportTaskId()));
    }

    return request;
  }
  public Request<ListBootstrapActionsRequest> marshall(
      ListBootstrapActionsRequest listBootstrapActionsRequest) {
    if (listBootstrapActionsRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<ListBootstrapActionsRequest> request =
        new DefaultRequest<ListBootstrapActionsRequest>(
            listBootstrapActionsRequest, "AmazonElasticMapReduce");
    String target = "ElasticMapReduce.ListBootstrapActions";
    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 (listBootstrapActionsRequest.getClusterId() != null) {
        jsonWriter.key("ClusterId").value(listBootstrapActionsRequest.getClusterId());
      }
      if (listBootstrapActionsRequest.getMarker() != null) {
        jsonWriter.key("Marker").value(listBootstrapActionsRequest.getMarker());
      }

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

    Request<DescribeInterconnectsRequest> request =
        new DefaultRequest<DescribeInterconnectsRequest>(
            describeInterconnectsRequest, "AmazonDirectConnect");
    String target = "OvertureService.DescribeInterconnects";
    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 (describeInterconnectsRequest.getInterconnectId() != null) {
        jsonWriter.key("interconnectId").value(describeInterconnectsRequest.getInterconnectId());
      }

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

    Request<EnableDomainTransferLockRequest> request =
        new DefaultRequest<EnableDomainTransferLockRequest>(
            enableDomainTransferLockRequest, "AmazonRoute53Domains");
    String target = "Route53Domains_v20140515.EnableDomainTransferLock";
    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 (enableDomainTransferLockRequest.getDomainName() != null) {
        jsonWriter.key("DomainName").value(enableDomainTransferLockRequest.getDomainName());
      }

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

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

    Request<ListRolesRequest> request =
        new DefaultRequest<ListRolesRequest>(listRolesRequest, "AmazonIdentityManagement");
    request.addParameter("Action", "ListRoles");
    request.addParameter("Version", "2010-05-08");

    if (listRolesRequest.getPathPrefix() != null) {
      request.addParameter("PathPrefix", StringUtils.fromString(listRolesRequest.getPathPrefix()));
    }
    if (listRolesRequest.getMarker() != null) {
      request.addParameter("Marker", StringUtils.fromString(listRolesRequest.getMarker()));
    }
    if (listRolesRequest.getMaxItems() != null) {
      request.addParameter("MaxItems", StringUtils.fromInteger(listRolesRequest.getMaxItems()));
    }

    return request;
  }
  public Request<AuthorizeSecurityGroupEgressRequest> marshall(
      AuthorizeSecurityGroupEgressRequest authorizeSecurityGroupEgressRequest) {

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

    Request<AuthorizeSecurityGroupEgressRequest> request =
        new DefaultRequest<AuthorizeSecurityGroupEgressRequest>(
            authorizeSecurityGroupEgressRequest, "AmazonEC2");
    request.addParameter("Action", "AuthorizeSecurityGroupEgress");
    request.addParameter("Version", "2014-06-15");

    if (authorizeSecurityGroupEgressRequest.getGroupId() != null) {
      request.addParameter(
          "GroupId", StringUtils.fromString(authorizeSecurityGroupEgressRequest.getGroupId()));
    }
    if (authorizeSecurityGroupEgressRequest.getSourceSecurityGroupName() != null) {
      request.addParameter(
          "SourceSecurityGroupName",
          StringUtils.fromString(authorizeSecurityGroupEgressRequest.getSourceSecurityGroupName()));
    }
    if (authorizeSecurityGroupEgressRequest.getSourceSecurityGroupOwnerId() != null) {
      request.addParameter(
          "SourceSecurityGroupOwnerId",
          StringUtils.fromString(
              authorizeSecurityGroupEgressRequest.getSourceSecurityGroupOwnerId()));
    }
    if (authorizeSecurityGroupEgressRequest.getIpProtocol() != null) {
      request.addParameter(
          "IpProtocol",
          StringUtils.fromString(authorizeSecurityGroupEgressRequest.getIpProtocol()));
    }
    if (authorizeSecurityGroupEgressRequest.getFromPort() != null) {
      request.addParameter(
          "FromPort", StringUtils.fromInteger(authorizeSecurityGroupEgressRequest.getFromPort()));
    }
    if (authorizeSecurityGroupEgressRequest.getToPort() != null) {
      request.addParameter(
          "ToPort", StringUtils.fromInteger(authorizeSecurityGroupEgressRequest.getToPort()));
    }
    if (authorizeSecurityGroupEgressRequest.getCidrIp() != null) {
      request.addParameter(
          "CidrIp", StringUtils.fromString(authorizeSecurityGroupEgressRequest.getCidrIp()));
    }

    java.util.List<IpPermission> ipPermissionsList =
        authorizeSecurityGroupEgressRequest.getIpPermissions();
    int ipPermissionsListIndex = 1;

    for (IpPermission ipPermissionsListValue : ipPermissionsList) {
      IpPermission ipPermissionMember = ipPermissionsListValue;
      if (ipPermissionMember != null) {
        if (ipPermissionMember.getIpProtocol() != null) {
          request.addParameter(
              "IpPermissions." + ipPermissionsListIndex + ".IpProtocol",
              StringUtils.fromString(ipPermissionMember.getIpProtocol()));
        }
        if (ipPermissionMember.getFromPort() != null) {
          request.addParameter(
              "IpPermissions." + ipPermissionsListIndex + ".FromPort",
              StringUtils.fromInteger(ipPermissionMember.getFromPort()));
        }
        if (ipPermissionMember.getToPort() != null) {
          request.addParameter(
              "IpPermissions." + ipPermissionsListIndex + ".ToPort",
              StringUtils.fromInteger(ipPermissionMember.getToPort()));
        }

        java.util.List<UserIdGroupPair> userIdGroupPairsList =
            ipPermissionMember.getUserIdGroupPairs();
        int userIdGroupPairsListIndex = 1;

        for (UserIdGroupPair userIdGroupPairsListValue : userIdGroupPairsList) {
          UserIdGroupPair userIdGroupPairMember = userIdGroupPairsListValue;
          if (userIdGroupPairMember != null) {
            if (userIdGroupPairMember.getUserId() != null) {
              request.addParameter(
                  "IpPermissions."
                      + ipPermissionsListIndex
                      + ".Groups."
                      + userIdGroupPairsListIndex
                      + ".UserId",
                  StringUtils.fromString(userIdGroupPairMember.getUserId()));
            }
            if (userIdGroupPairMember.getGroupName() != null) {
              request.addParameter(
                  "IpPermissions."
                      + ipPermissionsListIndex
                      + ".Groups."
                      + userIdGroupPairsListIndex
                      + ".GroupName",
                  StringUtils.fromString(userIdGroupPairMember.getGroupName()));
            }
            if (userIdGroupPairMember.getGroupId() != null) {
              request.addParameter(
                  "IpPermissions."
                      + ipPermissionsListIndex
                      + ".Groups."
                      + userIdGroupPairsListIndex
                      + ".GroupId",
                  StringUtils.fromString(userIdGroupPairMember.getGroupId()));
            }
          }

          userIdGroupPairsListIndex++;
        }

        java.util.List<String> ipRangesList = ipPermissionMember.getIpRanges();
        int ipRangesListIndex = 1;

        for (String ipRangesListValue : ipRangesList) {
          if (ipRangesListValue != null) {
            request.addParameter(
                "IpPermissions."
                    + ipPermissionsListIndex
                    + ".IpRanges."
                    + ipRangesListIndex
                    + ".CidrIp",
                StringUtils.fromString(ipRangesListValue));
          }

          ipRangesListIndex++;
        }
      }

      ipPermissionsListIndex++;
    }

    return request;
  }
  public Request<CreateImageRequest> marshall(CreateImageRequest createImageRequest) {

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

    Request<CreateImageRequest> request =
        new DefaultRequest<CreateImageRequest>(createImageRequest, "AmazonEC2");
    request.addParameter("Action", "CreateImage");
    request.addParameter("Version", "2014-06-15");

    if (createImageRequest.getInstanceId() != null) {
      request.addParameter(
          "InstanceId", StringUtils.fromString(createImageRequest.getInstanceId()));
    }
    if (createImageRequest.getName() != null) {
      request.addParameter("Name", StringUtils.fromString(createImageRequest.getName()));
    }
    if (createImageRequest.getDescription() != null) {
      request.addParameter(
          "Description", StringUtils.fromString(createImageRequest.getDescription()));
    }
    if (createImageRequest.isNoReboot() != null) {
      request.addParameter("NoReboot", StringUtils.fromBoolean(createImageRequest.isNoReboot()));
    }

    java.util.List<BlockDeviceMapping> blockDeviceMappingsList =
        createImageRequest.getBlockDeviceMappings();
    int blockDeviceMappingsListIndex = 1;

    for (BlockDeviceMapping blockDeviceMappingsListValue : blockDeviceMappingsList) {
      BlockDeviceMapping blockDeviceMappingMember = blockDeviceMappingsListValue;
      if (blockDeviceMappingMember != null) {
        if (blockDeviceMappingMember.getVirtualName() != null) {
          request.addParameter(
              "BlockDeviceMapping." + blockDeviceMappingsListIndex + ".VirtualName",
              StringUtils.fromString(blockDeviceMappingMember.getVirtualName()));
        }
        if (blockDeviceMappingMember.getDeviceName() != null) {
          request.addParameter(
              "BlockDeviceMapping." + blockDeviceMappingsListIndex + ".DeviceName",
              StringUtils.fromString(blockDeviceMappingMember.getDeviceName()));
        }
        EbsBlockDevice ebsBlockDeviceEbs = blockDeviceMappingMember.getEbs();
        if (ebsBlockDeviceEbs != null) {
          if (ebsBlockDeviceEbs.getSnapshotId() != null) {
            request.addParameter(
                "BlockDeviceMapping." + blockDeviceMappingsListIndex + ".Ebs.SnapshotId",
                StringUtils.fromString(ebsBlockDeviceEbs.getSnapshotId()));
          }
          if (ebsBlockDeviceEbs.getVolumeSize() != null) {
            request.addParameter(
                "BlockDeviceMapping." + blockDeviceMappingsListIndex + ".Ebs.VolumeSize",
                StringUtils.fromInteger(ebsBlockDeviceEbs.getVolumeSize()));
          }
          if (ebsBlockDeviceEbs.isDeleteOnTermination() != null) {
            request.addParameter(
                "BlockDeviceMapping." + blockDeviceMappingsListIndex + ".Ebs.DeleteOnTermination",
                StringUtils.fromBoolean(ebsBlockDeviceEbs.isDeleteOnTermination()));
          }
          if (ebsBlockDeviceEbs.getVolumeType() != null) {
            request.addParameter(
                "BlockDeviceMapping." + blockDeviceMappingsListIndex + ".Ebs.VolumeType",
                StringUtils.fromString(ebsBlockDeviceEbs.getVolumeType()));
          }
          if (ebsBlockDeviceEbs.getIops() != null) {
            request.addParameter(
                "BlockDeviceMapping." + blockDeviceMappingsListIndex + ".Ebs.Iops",
                StringUtils.fromInteger(ebsBlockDeviceEbs.getIops()));
          }
          if (ebsBlockDeviceEbs.isEncrypted() != null) {
            request.addParameter(
                "BlockDeviceMapping." + blockDeviceMappingsListIndex + ".Ebs.Encrypted",
                StringUtils.fromBoolean(ebsBlockDeviceEbs.isEncrypted()));
          }
        }
        if (blockDeviceMappingMember.getNoDevice() != null) {
          request.addParameter(
              "BlockDeviceMapping." + blockDeviceMappingsListIndex + ".NoDevice",
              StringUtils.fromString(blockDeviceMappingMember.getNoDevice()));
        }
      }

      blockDeviceMappingsListIndex++;
    }

    return request;
  }