コード例 #1
0
  public Request<ListDocumentsRequest> marshall(ListDocumentsRequest listDocumentsRequest) {

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

    Request<ListDocumentsRequest> request =
        new DefaultRequest<ListDocumentsRequest>(
            listDocumentsRequest, "AWSSimpleSystemsManagement");
    request.addHeader("X-Amz-Target", "AmazonSSM.ListDocuments");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      com.amazonaws.internal.SdkInternalList<DocumentFilter> documentFilterListList =
          (com.amazonaws.internal.SdkInternalList<DocumentFilter>)
              listDocumentsRequest.getDocumentFilterList();
      if (!documentFilterListList.isEmpty() || !documentFilterListList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("DocumentFilterList");
        jsonGenerator.writeStartArray();
        for (DocumentFilter documentFilterListListValue : documentFilterListList) {
          if (documentFilterListListValue != null) {

            DocumentFilterJsonMarshaller.getInstance()
                .marshall(documentFilterListListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (listDocumentsRequest.getMaxResults() != null) {
        jsonGenerator.writeFieldName("MaxResults").writeValue(listDocumentsRequest.getMaxResults());
      }
      if (listDocumentsRequest.getNextToken() != null) {
        jsonGenerator.writeFieldName("NextToken").writeValue(listDocumentsRequest.getNextToken());
      }

      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 SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<DescribeAssociationRequest> marshall(
      DescribeAssociationRequest describeAssociationRequest) {

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

    Request<DescribeAssociationRequest> request =
        new DefaultRequest<DescribeAssociationRequest>(
            describeAssociationRequest, "AWSSimpleSystemsManagement");
    request.addHeader("X-Amz-Target", "AmazonSSM.DescribeAssociation");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (describeAssociationRequest.getName() != null) {
        jsonGenerator.writeFieldName("Name").writeValue(describeAssociationRequest.getName());
      }
      if (describeAssociationRequest.getInstanceId() != null) {
        jsonGenerator
            .writeFieldName("InstanceId")
            .writeValue(describeAssociationRequest.getInstanceId());
      }
      if (describeAssociationRequest.getAssociationId() != null) {
        jsonGenerator
            .writeFieldName("AssociationId")
            .writeValue(describeAssociationRequest.getAssociationId());
      }

      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 SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }