public Request<CreateResourceGroupRequest> marshall( CreateResourceGroupRequest createResourceGroupRequest) { if (createResourceGroupRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<CreateResourceGroupRequest> request = new DefaultRequest<CreateResourceGroupRequest>( createResourceGroupRequest, "AmazonInspector"); request.addHeader("X-Amz-Target", "InspectorService.CreateResourceGroup"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); if (createResourceGroupRequest.getResourceGroupTags() != null) { jsonWriter .key("resourceGroupTags") .value(createResourceGroupRequest.getResourceGroupTags()); } 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.1"); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }
/** Marshall the given parameter object, and output to a JSONWriter */ public void marshall(Telemetry telemetry, JSONWriter jsonWriter) { if (telemetry == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonWriter.object(); if (telemetry.getStatus() != null) { jsonWriter.key("status").value(telemetry.getStatus()); } java.util.List<MessageTypeTelemetry> messageTypeTelemetriesList = telemetry.getMessageTypeTelemetries(); if (messageTypeTelemetriesList != null) { jsonWriter.key("messageTypeTelemetries"); jsonWriter.array(); for (MessageTypeTelemetry messageTypeTelemetriesListValue : messageTypeTelemetriesList) { if (messageTypeTelemetriesListValue != null) { MessageTypeTelemetryJsonMarshaller.getInstance() .marshall(messageTypeTelemetriesListValue, jsonWriter); } } jsonWriter.endArray(); } jsonWriter.endObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
public Request<ListApplicationsRequest> marshall( ListApplicationsRequest listApplicationsRequest) { if (listApplicationsRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<ListApplicationsRequest> request = new DefaultRequest<ListApplicationsRequest>(listApplicationsRequest, "AmazonInspector"); request.addHeader("X-Amz-Target", "InspectorService.ListApplications"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); if (listApplicationsRequest.getFilter() != null) { jsonWriter.key("filter"); ApplicationsFilterJsonMarshaller.getInstance() .marshall(listApplicationsRequest.getFilter(), jsonWriter); } if (listApplicationsRequest.getNextToken() != null) { jsonWriter.key("nextToken").value(listApplicationsRequest.getNextToken()); } if (listApplicationsRequest.getMaxResults() != null) { jsonWriter.key("maxResults").value(listApplicationsRequest.getMaxResults()); } 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.1"); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }