コード例 #1
0
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(ParameterObject parameterObject, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (parameterObject.getId() != null) {
        jsonGenerator.writeFieldName("id").writeValue(parameterObject.getId());
      }

      com.amazonaws.internal.SdkInternalList<ParameterAttribute> attributesList =
          (com.amazonaws.internal.SdkInternalList<ParameterAttribute>)
              parameterObject.getAttributes();
      if (!attributesList.isEmpty() || !attributesList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("attributes");
        jsonGenerator.writeStartArray();
        for (ParameterAttribute attributesListValue : attributesList) {
          if (attributesListValue != null) {

            ParameterAttributeJsonMarshaller.getInstance()
                .marshall(attributesListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<DescribeEcsClustersRequest> marshall(
      DescribeEcsClustersRequest describeEcsClustersRequest) {

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

    Request<DescribeEcsClustersRequest> request =
        new DefaultRequest<DescribeEcsClustersRequest>(describeEcsClustersRequest, "AWSOpsWorks");
    request.addHeader("X-Amz-Target", "OpsWorks_20130218.DescribeEcsClusters");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      com.amazonaws.internal.SdkInternalList<String> ecsClusterArnsList =
          (com.amazonaws.internal.SdkInternalList<String>)
              describeEcsClustersRequest.getEcsClusterArns();
      if (!ecsClusterArnsList.isEmpty() || !ecsClusterArnsList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("EcsClusterArns");
        jsonGenerator.writeStartArray();
        for (String ecsClusterArnsListValue : ecsClusterArnsList) {
          if (ecsClusterArnsListValue != null) {
            jsonGenerator.writeValue(ecsClusterArnsListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (describeEcsClustersRequest.getStackId() != null) {
        jsonGenerator.writeFieldName("StackId").writeValue(describeEcsClustersRequest.getStackId());
      }
      if (describeEcsClustersRequest.getNextToken() != null) {
        jsonGenerator
            .writeFieldName("NextToken")
            .writeValue(describeEcsClustersRequest.getNextToken());
      }
      if (describeEcsClustersRequest.getMaxResults() != null) {
        jsonGenerator
            .writeFieldName("MaxResults")
            .writeValue(describeEcsClustersRequest.getMaxResults());
      }

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

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

    Request<DescribeRulesPackagesRequest> request =
        new DefaultRequest<DescribeRulesPackagesRequest>(
            describeRulesPackagesRequest, "AmazonInspector");
    request.addHeader("X-Amz-Target", "InspectorService.DescribeRulesPackages");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      java.util.List<String> rulesPackageArnsList =
          describeRulesPackagesRequest.getRulesPackageArns();
      if (rulesPackageArnsList != null) {
        jsonGenerator.writeFieldName("rulesPackageArns");
        jsonGenerator.writeStartArray();
        for (String rulesPackageArnsListValue : rulesPackageArnsList) {
          if (rulesPackageArnsListValue != null) {
            jsonGenerator.writeValue(rulesPackageArnsListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (describeRulesPackagesRequest.getLocale() != null) {
        jsonGenerator.writeFieldName("locale").writeValue(describeRulesPackagesRequest.getLocale());
      }

      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;
  }
コード例 #4
0
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(JobOutput jobOutput, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (jobOutput.getId() != null) {
        jsonGenerator.writeFieldName("Id").writeValue(jobOutput.getId());
      }
      if (jobOutput.getKey() != null) {
        jsonGenerator.writeFieldName("Key").writeValue(jobOutput.getKey());
      }
      if (jobOutput.getThumbnailPattern() != null) {
        jsonGenerator
            .writeFieldName("ThumbnailPattern")
            .writeValue(jobOutput.getThumbnailPattern());
      }
      if (jobOutput.getThumbnailEncryption() != null) {
        jsonGenerator.writeFieldName("ThumbnailEncryption");
        EncryptionJsonMarshaller.getInstance()
            .marshall(jobOutput.getThumbnailEncryption(), jsonGenerator);
      }
      if (jobOutput.getRotate() != null) {
        jsonGenerator.writeFieldName("Rotate").writeValue(jobOutput.getRotate());
      }
      if (jobOutput.getPresetId() != null) {
        jsonGenerator.writeFieldName("PresetId").writeValue(jobOutput.getPresetId());
      }
      if (jobOutput.getSegmentDuration() != null) {
        jsonGenerator.writeFieldName("SegmentDuration").writeValue(jobOutput.getSegmentDuration());
      }
      if (jobOutput.getStatus() != null) {
        jsonGenerator.writeFieldName("Status").writeValue(jobOutput.getStatus());
      }
      if (jobOutput.getStatusDetail() != null) {
        jsonGenerator.writeFieldName("StatusDetail").writeValue(jobOutput.getStatusDetail());
      }
      if (jobOutput.getDuration() != null) {
        jsonGenerator.writeFieldName("Duration").writeValue(jobOutput.getDuration());
      }
      if (jobOutput.getWidth() != null) {
        jsonGenerator.writeFieldName("Width").writeValue(jobOutput.getWidth());
      }
      if (jobOutput.getHeight() != null) {
        jsonGenerator.writeFieldName("Height").writeValue(jobOutput.getHeight());
      }
      if (jobOutput.getFrameRate() != null) {
        jsonGenerator.writeFieldName("FrameRate").writeValue(jobOutput.getFrameRate());
      }
      if (jobOutput.getFileSize() != null) {
        jsonGenerator.writeFieldName("FileSize").writeValue(jobOutput.getFileSize());
      }
      if (jobOutput.getDurationMillis() != null) {
        jsonGenerator.writeFieldName("DurationMillis").writeValue(jobOutput.getDurationMillis());
      }

      com.amazonaws.internal.SdkInternalList<JobWatermark> watermarksList =
          (com.amazonaws.internal.SdkInternalList<JobWatermark>) jobOutput.getWatermarks();
      if (!watermarksList.isEmpty() || !watermarksList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("Watermarks");
        jsonGenerator.writeStartArray();
        for (JobWatermark watermarksListValue : watermarksList) {
          if (watermarksListValue != null) {

            JobWatermarkJsonMarshaller.getInstance().marshall(watermarksListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (jobOutput.getAlbumArt() != null) {
        jsonGenerator.writeFieldName("AlbumArt");
        JobAlbumArtJsonMarshaller.getInstance().marshall(jobOutput.getAlbumArt(), jsonGenerator);
      }

      com.amazonaws.internal.SdkInternalList<Clip> compositionList =
          (com.amazonaws.internal.SdkInternalList<Clip>) jobOutput.getComposition();
      if (!compositionList.isEmpty() || !compositionList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("Composition");
        jsonGenerator.writeStartArray();
        for (Clip compositionListValue : compositionList) {
          if (compositionListValue != null) {

            ClipJsonMarshaller.getInstance().marshall(compositionListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (jobOutput.getCaptions() != null) {
        jsonGenerator.writeFieldName("Captions");
        CaptionsJsonMarshaller.getInstance().marshall(jobOutput.getCaptions(), jsonGenerator);
      }
      if (jobOutput.getEncryption() != null) {
        jsonGenerator.writeFieldName("Encryption");
        EncryptionJsonMarshaller.getInstance().marshall(jobOutput.getEncryption(), jsonGenerator);
      }
      if (jobOutput.getAppliedColorSpaceConversion() != null) {
        jsonGenerator
            .writeFieldName("AppliedColorSpaceConversion")
            .writeValue(jobOutput.getAppliedColorSpaceConversion());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }