/** Marshall the given parameter object, and output to a SdkJsonGenerator */ public void marshall(MetricFilter metricFilter, StructuredJsonGenerator jsonGenerator) { if (metricFilter == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (metricFilter.getFilterName() != null) { jsonGenerator.writeFieldName("filterName").writeValue(metricFilter.getFilterName()); } if (metricFilter.getFilterPattern() != null) { jsonGenerator.writeFieldName("filterPattern").writeValue(metricFilter.getFilterPattern()); } com.amazonaws.internal.SdkInternalList<MetricTransformation> metricTransformationsList = (com.amazonaws.internal.SdkInternalList<MetricTransformation>) metricFilter.getMetricTransformations(); if (!metricTransformationsList.isEmpty() || !metricTransformationsList.isAutoConstruct()) { jsonGenerator.writeFieldName("metricTransformations"); jsonGenerator.writeStartArray(); for (MetricTransformation metricTransformationsListValue : metricTransformationsList) { if (metricTransformationsListValue != null) { MetricTransformationJsonMarshaller.getInstance() .marshall(metricTransformationsListValue, jsonGenerator); } } jsonGenerator.writeEndArray(); } if (metricFilter.getCreationTime() != null) { jsonGenerator.writeFieldName("creationTime").writeValue(metricFilter.getCreationTime()); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
public Request<PutMetricFilterRequest> marshall(PutMetricFilterRequest putMetricFilterRequest) { if (putMetricFilterRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<PutMetricFilterRequest> request = new DefaultRequest<PutMetricFilterRequest>(putMetricFilterRequest, "AWSLogs"); request.addHeader("X-Amz-Target", "Logs_20140328.PutMetricFilter"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); if (putMetricFilterRequest.getLogGroupName() != null) { jsonGenerator .writeFieldName("logGroupName") .writeValue(putMetricFilterRequest.getLogGroupName()); } if (putMetricFilterRequest.getFilterName() != null) { jsonGenerator .writeFieldName("filterName") .writeValue(putMetricFilterRequest.getFilterName()); } if (putMetricFilterRequest.getFilterPattern() != null) { jsonGenerator .writeFieldName("filterPattern") .writeValue(putMetricFilterRequest.getFilterPattern()); } com.amazonaws.internal.SdkInternalList<MetricTransformation> metricTransformationsList = (com.amazonaws.internal.SdkInternalList<MetricTransformation>) putMetricFilterRequest.getMetricTransformations(); if (!metricTransformationsList.isEmpty() || !metricTransformationsList.isAutoConstruct()) { jsonGenerator.writeFieldName("metricTransformations"); jsonGenerator.writeStartArray(); for (MetricTransformation metricTransformationsListValue : metricTransformationsList) { if (metricTransformationsListValue != null) { MetricTransformationJsonMarshaller.getInstance() .marshall(metricTransformationsListValue, 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 SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }