public Request<DescribeNFSFileSharesRequest> marshall(
      DescribeNFSFileSharesRequest describeNFSFileSharesRequest) {

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

    Request<DescribeNFSFileSharesRequest> request =
        new DefaultRequest<DescribeNFSFileSharesRequest>(
            describeNFSFileSharesRequest, "AWSStorageGateway");
    request.addHeader("X-Amz-Target", "StorageGateway_20130630.DescribeNFSFileShares");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      com.amazonaws.internal.SdkInternalList<String> fileShareARNListList =
          (com.amazonaws.internal.SdkInternalList<String>)
              describeNFSFileSharesRequest.getFileShareARNList();
      if (!fileShareARNListList.isEmpty() || !fileShareARNListList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("FileShareARNList");
        jsonGenerator.writeStartArray();
        for (String fileShareARNListListValue : fileShareARNListList) {
          if (fileShareARNListListValue != null) {
            jsonGenerator.writeValue(fileShareARNListListValue);
          }
        }
        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", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

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

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

    Request<ListTagsForResourceRequest> request =
        new DefaultRequest<ListTagsForResourceRequest>(
            listTagsForResourceRequest, "AWSStorageGateway");
    request.addHeader("X-Amz-Target", "StorageGateway_20130630.ListTagsForResource");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (listTagsForResourceRequest.getResourceARN() != null) {
        jsonGenerator
            .writeFieldName("ResourceARN")
            .writeValue(listTagsForResourceRequest.getResourceARN());
      }
      if (listTagsForResourceRequest.getMarker() != null) {
        jsonGenerator.writeFieldName("Marker").writeValue(listTagsForResourceRequest.getMarker());
      }
      if (listTagsForResourceRequest.getLimit() != null) {
        jsonGenerator.writeFieldName("Limit").writeValue(listTagsForResourceRequest.getLimit());
      }

      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;
  }
コード例 #3
0
  public Request<CreateSnapshotRequest> marshall(CreateSnapshotRequest createSnapshotRequest) {

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

    Request<CreateSnapshotRequest> request =
        new DefaultRequest<CreateSnapshotRequest>(createSnapshotRequest, "AWSStorageGateway");
    request.addHeader("X-Amz-Target", "StorageGateway_20130630.CreateSnapshot");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator =
          SdkJsonProtocolFactory.createWriter(false, "1.1");

      jsonGenerator.writeStartObject();

      if (createSnapshotRequest.getVolumeARN() != null) {
        jsonGenerator.writeFieldName("VolumeARN").writeValue(createSnapshotRequest.getVolumeARN());
      }
      if (createSnapshotRequest.getSnapshotDescription() != null) {
        jsonGenerator
            .writeFieldName("SnapshotDescription")
            .writeValue(createSnapshotRequest.getSnapshotDescription());
      }

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