public Request<DescribeRulesPackagesRequest> marshall( DescribeRulesPackagesRequest describeRulesPackagesRequest) { if (describeRulesPackagesRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<DescribeRulesPackagesRequest> request = new DefaultRequest<DescribeRulesPackagesRequest>( describeRulesPackagesRequest, "AmazonInspector"); request.addHeader("X-Amz-Target", "InspectorService.DescribeRulesPackages"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = SdkJsonProtocolFactory.createWriter(false, "1.1"); jsonGenerator.writeStartObject(); java.util.List<String> rulesPackageArnsList = describeRulesPackagesRequest.getRulesPackageArns(); if (rulesPackageArnsList != null) { jsonGenerator.writeFieldName("rulesPackageArns"); jsonGenerator.writeStartArray(); for (String rulesPackageArnsListValue : rulesPackageArnsList) { if (rulesPackageArnsListValue != null) { jsonGenerator.writeValue(rulesPackageArnsListValue); } } jsonGenerator.writeEndArray(); } if (describeRulesPackagesRequest.getLocale() != null) { jsonGenerator.writeFieldName("locale").writeValue(describeRulesPackagesRequest.getLocale()); } jsonGenerator.writeEndObject(); byte[] content = jsonGenerator.getBytes(); request.setContent(new ByteArrayInputStream(content)); request.addHeader("Content-Length", Integer.toString(content.length)); request.addHeader("Content-Type", jsonGenerator.getContentType()); } 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(ResourceGroupTag resourceGroupTag, StructuredJsonGenerator jsonGenerator) { if (resourceGroupTag == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (resourceGroupTag.getKey() != null) { jsonGenerator.writeFieldName("key").writeValue(resourceGroupTag.getKey()); } if (resourceGroupTag.getValue() != null) { jsonGenerator.writeFieldName("value").writeValue(resourceGroupTag.getValue()); } jsonGenerator.writeEndObject(); } 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(Finding finding, StructuredJsonGenerator jsonGenerator) { if (finding == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (finding.getArn() != null) { jsonGenerator.writeFieldName("arn").writeValue(finding.getArn()); } if (finding.getSchemaVersion() != null) { jsonGenerator.writeFieldName("schemaVersion").writeValue(finding.getSchemaVersion()); } if (finding.getService() != null) { jsonGenerator.writeFieldName("service").writeValue(finding.getService()); } if (finding.getServiceAttributes() != null) { jsonGenerator.writeFieldName("serviceAttributes"); InspectorServiceAttributesJsonMarshaller.getInstance() .marshall(finding.getServiceAttributes(), jsonGenerator); } if (finding.getAssetType() != null) { jsonGenerator.writeFieldName("assetType").writeValue(finding.getAssetType()); } if (finding.getAssetAttributes() != null) { jsonGenerator.writeFieldName("assetAttributes"); AssetAttributesJsonMarshaller.getInstance() .marshall(finding.getAssetAttributes(), jsonGenerator); } if (finding.getId() != null) { jsonGenerator.writeFieldName("id").writeValue(finding.getId()); } if (finding.getTitle() != null) { jsonGenerator.writeFieldName("title").writeValue(finding.getTitle()); } if (finding.getDescription() != null) { jsonGenerator.writeFieldName("description").writeValue(finding.getDescription()); } if (finding.getRecommendation() != null) { jsonGenerator.writeFieldName("recommendation").writeValue(finding.getRecommendation()); } if (finding.getSeverity() != null) { jsonGenerator.writeFieldName("severity").writeValue(finding.getSeverity()); } if (finding.getNumericSeverity() != null) { jsonGenerator.writeFieldName("numericSeverity").writeValue(finding.getNumericSeverity()); } if (finding.getConfidence() != null) { jsonGenerator.writeFieldName("confidence").writeValue(finding.getConfidence()); } if (finding.getIndicatorOfCompromise() != null) { jsonGenerator .writeFieldName("indicatorOfCompromise") .writeValue(finding.getIndicatorOfCompromise()); } java.util.List<Attribute> attributesList = finding.getAttributes(); if (attributesList != null) { jsonGenerator.writeFieldName("attributes"); jsonGenerator.writeStartArray(); for (Attribute attributesListValue : attributesList) { if (attributesListValue != null) { AttributeJsonMarshaller.getInstance().marshall(attributesListValue, jsonGenerator); } } jsonGenerator.writeEndArray(); } java.util.List<Attribute> userAttributesList = finding.getUserAttributes(); if (userAttributesList != null) { jsonGenerator.writeFieldName("userAttributes"); jsonGenerator.writeStartArray(); for (Attribute userAttributesListValue : userAttributesList) { if (userAttributesListValue != null) { AttributeJsonMarshaller.getInstance().marshall(userAttributesListValue, jsonGenerator); } } jsonGenerator.writeEndArray(); } if (finding.getCreatedAt() != null) { jsonGenerator.writeFieldName("createdAt").writeValue(finding.getCreatedAt()); } if (finding.getUpdatedAt() != null) { jsonGenerator.writeFieldName("updatedAt").writeValue(finding.getUpdatedAt()); } jsonGenerator.writeEndObject(); } 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( AssessmentRunFilter assessmentRunFilter, StructuredJsonGenerator jsonGenerator) { if (assessmentRunFilter == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (assessmentRunFilter.getNamePattern() != null) { jsonGenerator .writeFieldName("namePattern") .writeValue(assessmentRunFilter.getNamePattern()); } java.util.List<String> statesList = assessmentRunFilter.getStates(); if (statesList != null) { jsonGenerator.writeFieldName("states"); jsonGenerator.writeStartArray(); for (String statesListValue : statesList) { if (statesListValue != null) { jsonGenerator.writeValue(statesListValue); } } jsonGenerator.writeEndArray(); } if (assessmentRunFilter.getDurationRange() != null) { jsonGenerator.writeFieldName("durationRange"); DurationRangeJsonMarshaller.getInstance() .marshall(assessmentRunFilter.getDurationRange(), jsonGenerator); } java.util.List<String> rulesPackageArnsList = assessmentRunFilter.getRulesPackageArns(); if (rulesPackageArnsList != null) { jsonGenerator.writeFieldName("rulesPackageArns"); jsonGenerator.writeStartArray(); for (String rulesPackageArnsListValue : rulesPackageArnsList) { if (rulesPackageArnsListValue != null) { jsonGenerator.writeValue(rulesPackageArnsListValue); } } jsonGenerator.writeEndArray(); } if (assessmentRunFilter.getStartTimeRange() != null) { jsonGenerator.writeFieldName("startTimeRange"); TimestampRangeJsonMarshaller.getInstance() .marshall(assessmentRunFilter.getStartTimeRange(), jsonGenerator); } if (assessmentRunFilter.getCompletionTimeRange() != null) { jsonGenerator.writeFieldName("completionTimeRange"); TimestampRangeJsonMarshaller.getInstance() .marshall(assessmentRunFilter.getCompletionTimeRange(), jsonGenerator); } if (assessmentRunFilter.getStateChangeTimeRange() != null) { jsonGenerator.writeFieldName("stateChangeTimeRange"); TimestampRangeJsonMarshaller.getInstance() .marshall(assessmentRunFilter.getStateChangeTimeRange(), jsonGenerator); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
public Request<CreateAssessmentTemplateRequest> marshall( CreateAssessmentTemplateRequest createAssessmentTemplateRequest) { if (createAssessmentTemplateRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<CreateAssessmentTemplateRequest> request = new DefaultRequest<CreateAssessmentTemplateRequest>( createAssessmentTemplateRequest, "AmazonInspector"); request.addHeader("X-Amz-Target", "InspectorService.CreateAssessmentTemplate"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); if (createAssessmentTemplateRequest.getAssessmentTargetArn() != null) { jsonGenerator .writeFieldName("assessmentTargetArn") .writeValue(createAssessmentTemplateRequest.getAssessmentTargetArn()); } if (createAssessmentTemplateRequest.getAssessmentTemplateName() != null) { jsonGenerator .writeFieldName("assessmentTemplateName") .writeValue(createAssessmentTemplateRequest.getAssessmentTemplateName()); } if (createAssessmentTemplateRequest.getDurationInSeconds() != null) { jsonGenerator .writeFieldName("durationInSeconds") .writeValue(createAssessmentTemplateRequest.getDurationInSeconds()); } java.util.List<String> rulesPackageArnsList = createAssessmentTemplateRequest.getRulesPackageArns(); if (rulesPackageArnsList != null) { jsonGenerator.writeFieldName("rulesPackageArns"); jsonGenerator.writeStartArray(); for (String rulesPackageArnsListValue : rulesPackageArnsList) { if (rulesPackageArnsListValue != null) { jsonGenerator.writeValue(rulesPackageArnsListValue); } } jsonGenerator.writeEndArray(); } java.util.List<Attribute> userAttributesForFindingsList = createAssessmentTemplateRequest.getUserAttributesForFindings(); if (userAttributesForFindingsList != null) { jsonGenerator.writeFieldName("userAttributesForFindings"); jsonGenerator.writeStartArray(); for (Attribute userAttributesForFindingsListValue : userAttributesForFindingsList) { if (userAttributesForFindingsListValue != null) { AttributeJsonMarshaller.getInstance() .marshall(userAttributesForFindingsListValue, 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; }
/** Marshall the given parameter object, and output to a SdkJsonGenerator */ public void marshall(AssessmentRun assessmentRun, StructuredJsonGenerator jsonGenerator) { if (assessmentRun == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (assessmentRun.getArn() != null) { jsonGenerator.writeFieldName("arn").writeValue(assessmentRun.getArn()); } if (assessmentRun.getName() != null) { jsonGenerator.writeFieldName("name").writeValue(assessmentRun.getName()); } if (assessmentRun.getAssessmentTemplateArn() != null) { jsonGenerator .writeFieldName("assessmentTemplateArn") .writeValue(assessmentRun.getAssessmentTemplateArn()); } if (assessmentRun.getState() != null) { jsonGenerator.writeFieldName("state").writeValue(assessmentRun.getState()); } if (assessmentRun.getDurationInSeconds() != null) { jsonGenerator .writeFieldName("durationInSeconds") .writeValue(assessmentRun.getDurationInSeconds()); } java.util.List<String> rulesPackageArnsList = assessmentRun.getRulesPackageArns(); if (rulesPackageArnsList != null) { jsonGenerator.writeFieldName("rulesPackageArns"); jsonGenerator.writeStartArray(); for (String rulesPackageArnsListValue : rulesPackageArnsList) { if (rulesPackageArnsListValue != null) { jsonGenerator.writeValue(rulesPackageArnsListValue); } } jsonGenerator.writeEndArray(); } java.util.List<Attribute> userAttributesForFindingsList = assessmentRun.getUserAttributesForFindings(); if (userAttributesForFindingsList != null) { jsonGenerator.writeFieldName("userAttributesForFindings"); jsonGenerator.writeStartArray(); for (Attribute userAttributesForFindingsListValue : userAttributesForFindingsList) { if (userAttributesForFindingsListValue != null) { AttributeJsonMarshaller.getInstance() .marshall(userAttributesForFindingsListValue, jsonGenerator); } } jsonGenerator.writeEndArray(); } if (assessmentRun.getCreatedAt() != null) { jsonGenerator.writeFieldName("createdAt").writeValue(assessmentRun.getCreatedAt()); } if (assessmentRun.getStartedAt() != null) { jsonGenerator.writeFieldName("startedAt").writeValue(assessmentRun.getStartedAt()); } if (assessmentRun.getCompletedAt() != null) { jsonGenerator.writeFieldName("completedAt").writeValue(assessmentRun.getCompletedAt()); } if (assessmentRun.getStateChangedAt() != null) { jsonGenerator .writeFieldName("stateChangedAt") .writeValue(assessmentRun.getStateChangedAt()); } if (assessmentRun.getDataCollected() != null) { jsonGenerator.writeFieldName("dataCollected").writeValue(assessmentRun.getDataCollected()); } java.util.List<AssessmentRunStateChange> stateChangesList = assessmentRun.getStateChanges(); if (stateChangesList != null) { jsonGenerator.writeFieldName("stateChanges"); jsonGenerator.writeStartArray(); for (AssessmentRunStateChange stateChangesListValue : stateChangesList) { if (stateChangesListValue != null) { AssessmentRunStateChangeJsonMarshaller.getInstance() .marshall(stateChangesListValue, jsonGenerator); } } jsonGenerator.writeEndArray(); } java.util.List<AssessmentRunNotification> notificationsList = assessmentRun.getNotifications(); if (notificationsList != null) { jsonGenerator.writeFieldName("notifications"); jsonGenerator.writeStartArray(); for (AssessmentRunNotification notificationsListValue : notificationsList) { if (notificationsListValue != null) { AssessmentRunNotificationJsonMarshaller.getInstance() .marshall(notificationsListValue, jsonGenerator); } } jsonGenerator.writeEndArray(); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }