コード例 #1
0
  public Request<UpdateShardCountRequest> marshall(
      UpdateShardCountRequest updateShardCountRequest) {

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

    Request<UpdateShardCountRequest> request =
        new DefaultRequest<UpdateShardCountRequest>(updateShardCountRequest, "AmazonKinesis");
    request.addHeader("X-Amz-Target", "Kinesis_20131202.UpdateShardCount");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (updateShardCountRequest.getStreamName() != null) {
        jsonGenerator
            .writeFieldName("StreamName")
            .writeValue(updateShardCountRequest.getStreamName());
      }
      if (updateShardCountRequest.getTargetShardCount() != null) {
        jsonGenerator
            .writeFieldName("TargetShardCount")
            .writeValue(updateShardCountRequest.getTargetShardCount());
      }
      if (updateShardCountRequest.getScalingType() != null) {
        jsonGenerator
            .writeFieldName("ScalingType")
            .writeValue(updateShardCountRequest.getScalingType());
      }

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

    Request<IncreaseStreamRetentionPeriodRequest> request =
        new DefaultRequest<IncreaseStreamRetentionPeriodRequest>(
            increaseStreamRetentionPeriodRequest, "AmazonKinesis");
    String target = "Kinesis_20131202.IncreaseStreamRetentionPeriod";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter);

      jsonWriter.beginObject();

      if (increaseStreamRetentionPeriodRequest.getStreamName() != null) {
        jsonWriter.name("StreamName").value(increaseStreamRetentionPeriodRequest.getStreamName());
      }
      if (increaseStreamRetentionPeriodRequest.getRetentionPeriodHours() != null) {
        jsonWriter
            .name("RetentionPeriodHours")
            .value(increaseStreamRetentionPeriodRequest.getRetentionPeriodHours());
      }

      jsonWriter.endObject();

      jsonWriter.close();
      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;
  }
コード例 #3
0
  public Request<GetRecordsRequest> marshall(GetRecordsRequest getRecordsRequest) {
    if (getRecordsRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(GetRecordsRequest)");
    }

    Request<GetRecordsRequest> request =
        new DefaultRequest<GetRecordsRequest>(getRecordsRequest, "AmazonKinesis");
    String target = "Kinesis_20131202.GetRecords";
    request.addHeader("X-Amz-Target", target);
    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "/";
    request.setResourcePath(uriResourcePath);
    try {
      StringWriter stringWriter = new StringWriter();
      AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter);
      jsonWriter.beginObject();

      if (getRecordsRequest.getShardIterator() != null) {
        String shardIterator = getRecordsRequest.getShardIterator();
        jsonWriter.name("ShardIterator");
        jsonWriter.value(shardIterator);
      }
      if (getRecordsRequest.getLimit() != null) {
        Integer limit = getRecordsRequest.getLimit();
        jsonWriter.name("Limit");
        jsonWriter.value(limit);
      }

      jsonWriter.endObject();
      jsonWriter.close();
      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    }

    return request;
  }