/** Marshall the given parameter object, and output to a SdkJsonGenerator */ public void marshall(IPSet iPSet, StructuredJsonGenerator jsonGenerator) { if (iPSet == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (iPSet.getIPSetId() != null) { jsonGenerator.writeFieldName("IPSetId").writeValue(iPSet.getIPSetId()); } if (iPSet.getName() != null) { jsonGenerator.writeFieldName("Name").writeValue(iPSet.getName()); } java.util.List<IPSetDescriptor> iPSetDescriptorsList = iPSet.getIPSetDescriptors(); if (iPSetDescriptorsList != null) { jsonGenerator.writeFieldName("IPSetDescriptors"); jsonGenerator.writeStartArray(); for (IPSetDescriptor iPSetDescriptorsListValue : iPSetDescriptorsList) { if (iPSetDescriptorsListValue != null) { IPSetDescriptorJsonMarshaller.getInstance() .marshall(iPSetDescriptorsListValue, jsonGenerator); } } jsonGenerator.writeEndArray(); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
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; }