コード例 #1
0
  public Request<DeleteTagsRequest> marshall(DeleteTagsRequest deleteTagsRequest) {

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

    Request<DeleteTagsRequest> request =
        new DefaultRequest<DeleteTagsRequest>(deleteTagsRequest, "AWSApplicationDiscovery");
    request.addHeader("X-Amz-Target", "AWSPoseidonService_V2015_11_01.DeleteTags");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      java.util.List<String> configurationIdsList = deleteTagsRequest.getConfigurationIds();
      if (configurationIdsList != null) {
        jsonGenerator.writeFieldName("configurationIds");
        jsonGenerator.writeStartArray();
        for (String configurationIdsListValue : configurationIdsList) {
          if (configurationIdsListValue != null) {
            jsonGenerator.writeValue(configurationIdsListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }

      java.util.List<Tag> tagsList = deleteTagsRequest.getTags();
      if (tagsList != null) {
        jsonGenerator.writeFieldName("tags");
        jsonGenerator.writeStartArray();
        for (Tag tagsListValue : tagsList) {
          if (tagsListValue != null) {

            TagJsonMarshaller.getInstance().marshall(tagsListValue, jsonGenerator);
          }
        }
        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", jsonGenerator.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
コード例 #2
0
  public Request<AddTagsRequest> marshall(AddTagsRequest addTagsRequest) {

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

    Request<AddTagsRequest> request =
        new DefaultRequest<AddTagsRequest>(addTagsRequest, "AWSElasticsearch");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "/2015-01-01/tags";

    request.setResourcePath(uriResourcePath);

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

      if (addTagsRequest.getARN() != null) {
        jsonGenerator.writeFieldName("ARN").writeValue(addTagsRequest.getARN());
      }

      java.util.List<Tag> tagListList = addTagsRequest.getTagList();
      if (tagListList != null) {
        jsonGenerator.writeFieldName("TagList");
        jsonGenerator.writeStartArray();
        for (Tag tagListListValue : tagListList) {
          if (tagListListValue != null) {

            TagJsonMarshaller.getInstance().marshall(tagListListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      if (!request.getHeaders().containsKey("Content-Type")) {
        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<RemoveTagsFromOnPremisesInstancesRequest> marshall(
      RemoveTagsFromOnPremisesInstancesRequest removeTagsFromOnPremisesInstancesRequest) {

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

    Request<RemoveTagsFromOnPremisesInstancesRequest> request =
        new DefaultRequest<RemoveTagsFromOnPremisesInstancesRequest>(
            removeTagsFromOnPremisesInstancesRequest, "AmazonCodeDeploy");
    request.addHeader("X-Amz-Target", "CodeDeploy_20141006.RemoveTagsFromOnPremisesInstances");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      com.amazonaws.internal.SdkInternalList<Tag> tagsList =
          (com.amazonaws.internal.SdkInternalList<Tag>)
              removeTagsFromOnPremisesInstancesRequest.getTags();
      if (!tagsList.isEmpty() || !tagsList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("tags");
        jsonGenerator.writeStartArray();
        for (Tag tagsListValue : tagsList) {
          if (tagsListValue != null) {

            TagJsonMarshaller.getInstance().marshall(tagsListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

      com.amazonaws.internal.SdkInternalList<String> instanceNamesList =
          (com.amazonaws.internal.SdkInternalList<String>)
              removeTagsFromOnPremisesInstancesRequest.getInstanceNames();
      if (!instanceNamesList.isEmpty() || !instanceNamesList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("instanceNames");
        jsonGenerator.writeStartArray();
        for (String instanceNamesListValue : instanceNamesList) {
          if (instanceNamesListValue != null) {
            jsonGenerator.writeValue(instanceNamesListValue);
          }
        }
        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", jsonGenerator.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }