public Request<UpdateByteMatchSetRequest> marshall( UpdateByteMatchSetRequest updateByteMatchSetRequest) { if (updateByteMatchSetRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<UpdateByteMatchSetRequest> request = new DefaultRequest<UpdateByteMatchSetRequest>(updateByteMatchSetRequest, "AWSWAF"); request.addHeader("X-Amz-Target", "AWSWAF_20150824.UpdateByteMatchSet"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); if (updateByteMatchSetRequest.getByteMatchSetId() != null) { jsonGenerator .writeFieldName("ByteMatchSetId") .writeValue(updateByteMatchSetRequest.getByteMatchSetId()); } if (updateByteMatchSetRequest.getChangeToken() != null) { jsonGenerator .writeFieldName("ChangeToken") .writeValue(updateByteMatchSetRequest.getChangeToken()); } java.util.List<ByteMatchSetUpdate> updatesList = updateByteMatchSetRequest.getUpdates(); if (updatesList != null) { jsonGenerator.writeFieldName("Updates"); jsonGenerator.writeStartArray(); for (ByteMatchSetUpdate updatesListValue : updatesList) { if (updatesListValue != null) { ByteMatchSetUpdateJsonMarshaller.getInstance() .marshall(updatesListValue, jsonGenerator); } } 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 AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }
public Request<CreateWebACLRequest> marshall(CreateWebACLRequest createWebACLRequest) { if (createWebACLRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<CreateWebACLRequest> request = new DefaultRequest<CreateWebACLRequest>(createWebACLRequest, "AWSWAFRegional"); request.addHeader("X-Amz-Target", "AWSWAF_Regional_20161128.CreateWebACL"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); if (createWebACLRequest.getName() != null) { jsonGenerator.writeFieldName("Name").writeValue(createWebACLRequest.getName()); } if (createWebACLRequest.getMetricName() != null) { jsonGenerator.writeFieldName("MetricName").writeValue(createWebACLRequest.getMetricName()); } if (createWebACLRequest.getDefaultAction() != null) { jsonGenerator.writeFieldName("DefaultAction"); WafActionJsonMarshaller.getInstance() .marshall(createWebACLRequest.getDefaultAction(), jsonGenerator); } if (createWebACLRequest.getChangeToken() != null) { jsonGenerator .writeFieldName("ChangeToken") .writeValue(createWebACLRequest.getChangeToken()); } 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; }