/** Marshall the given parameter object, and output to a SdkJsonGenerator */ public void marshall( RejectedLogEventsInfo rejectedLogEventsInfo, StructuredJsonGenerator jsonGenerator) { if (rejectedLogEventsInfo == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (rejectedLogEventsInfo.getTooNewLogEventStartIndex() != null) { jsonGenerator .writeFieldName("tooNewLogEventStartIndex") .writeValue(rejectedLogEventsInfo.getTooNewLogEventStartIndex()); } if (rejectedLogEventsInfo.getTooOldLogEventEndIndex() != null) { jsonGenerator .writeFieldName("tooOldLogEventEndIndex") .writeValue(rejectedLogEventsInfo.getTooOldLogEventEndIndex()); } if (rejectedLogEventsInfo.getExpiredLogEventEndIndex() != null) { jsonGenerator .writeFieldName("expiredLogEventEndIndex") .writeValue(rejectedLogEventsInfo.getExpiredLogEventEndIndex()); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
public Request<PutSubscriptionFilterRequest> marshall( PutSubscriptionFilterRequest putSubscriptionFilterRequest) { if (putSubscriptionFilterRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<PutSubscriptionFilterRequest> request = new DefaultRequest<PutSubscriptionFilterRequest>(putSubscriptionFilterRequest, "AWSLogs"); String target = "Logs_20140328.PutSubscriptionFilter"; request.addHeader("X-Amz-Target", target); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); if (putSubscriptionFilterRequest.getLogGroupName() != null) { jsonWriter.key("logGroupName").value(putSubscriptionFilterRequest.getLogGroupName()); } if (putSubscriptionFilterRequest.getFilterName() != null) { jsonWriter.key("filterName").value(putSubscriptionFilterRequest.getFilterName()); } if (putSubscriptionFilterRequest.getFilterPattern() != null) { jsonWriter.key("filterPattern").value(putSubscriptionFilterRequest.getFilterPattern()); } if (putSubscriptionFilterRequest.getDestinationArn() != null) { jsonWriter.key("destinationArn").value(putSubscriptionFilterRequest.getDestinationArn()); } if (putSubscriptionFilterRequest.getRoleArn() != null) { jsonWriter.key("roleArn").value(putSubscriptionFilterRequest.getRoleArn()); } 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 SdkJsonGenerator */ public void marshall(ExportTask exportTask, StructuredJsonGenerator jsonGenerator) { if (exportTask == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (exportTask.getTaskId() != null) { jsonGenerator.writeFieldName("taskId").writeValue(exportTask.getTaskId()); } if (exportTask.getTaskName() != null) { jsonGenerator.writeFieldName("taskName").writeValue(exportTask.getTaskName()); } if (exportTask.getLogGroupName() != null) { jsonGenerator.writeFieldName("logGroupName").writeValue(exportTask.getLogGroupName()); } if (exportTask.getFrom() != null) { jsonGenerator.writeFieldName("from").writeValue(exportTask.getFrom()); } if (exportTask.getTo() != null) { jsonGenerator.writeFieldName("to").writeValue(exportTask.getTo()); } if (exportTask.getDestination() != null) { jsonGenerator.writeFieldName("destination").writeValue(exportTask.getDestination()); } if (exportTask.getDestinationPrefix() != null) { jsonGenerator .writeFieldName("destinationPrefix") .writeValue(exportTask.getDestinationPrefix()); } if (exportTask.getStatus() != null) { jsonGenerator.writeFieldName("status"); ExportTaskStatusJsonMarshaller.getInstance() .marshall(exportTask.getStatus(), jsonGenerator); } if (exportTask.getExecutionInfo() != null) { jsonGenerator.writeFieldName("executionInfo"); ExportTaskExecutionInfoJsonMarshaller.getInstance() .marshall(exportTask.getExecutionInfo(), jsonGenerator); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
/** Marshall the given parameter object, and output to a JSONWriter */ public void marshall(ExportTaskStatus exportTaskStatus, JSONWriter jsonWriter) { if (exportTaskStatus == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonWriter.object(); if (exportTaskStatus.getCode() != null) { jsonWriter.key("code").value(exportTaskStatus.getCode()); } if (exportTaskStatus.getMessage() != null) { jsonWriter.key("message").value(exportTaskStatus.getMessage()); } jsonWriter.endObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
/** 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; }