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; }
/** Marshall the given parameter object, and output to a JSONWriter */ public void marshall(WebACL webACL, JSONWriter jsonWriter) { if (webACL == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonWriter.object(); if (webACL.getWebACLId() != null) { jsonWriter.key("WebACLId").value(webACL.getWebACLId()); } if (webACL.getName() != null) { jsonWriter.key("Name").value(webACL.getName()); } if (webACL.getMetricName() != null) { jsonWriter.key("MetricName").value(webACL.getMetricName()); } if (webACL.getDefaultAction() != null) { jsonWriter.key("DefaultAction"); WafActionJsonMarshaller.getInstance().marshall(webACL.getDefaultAction(), jsonWriter); } java.util.List<ActivatedRule> rulesList = webACL.getRules(); if (rulesList != null) { jsonWriter.key("Rules"); jsonWriter.array(); for (ActivatedRule rulesListValue : rulesList) { if (rulesListValue != null) { ActivatedRuleJsonMarshaller.getInstance().marshall(rulesListValue, jsonWriter); } } jsonWriter.endArray(); } jsonWriter.endObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }