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; }
public Request<GetRecordsRequest> marshall(GetRecordsRequest getRecordsRequest) { if (getRecordsRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<GetRecordsRequest> request = new DefaultRequest<GetRecordsRequest>(getRecordsRequest, "AmazonDynamoDBStreams"); request.addHeader("X-Amz-Target", "DynamoDBStreams_20120810.GetRecords"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); if (getRecordsRequest.getShardIterator() != null) { jsonWriter.key("ShardIterator").value(getRecordsRequest.getShardIterator()); } if (getRecordsRequest.getLimit() != null) { jsonWriter.key("Limit").value(getRecordsRequest.getLimit()); } jsonWriter.endObject(); 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.0"); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }