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;
  }
コード例 #2
0
  /** 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;
  }
コード例 #4
0
  /** 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);
    }
  }