/** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      VaultNotificationConfig vaultNotificationConfig, StructuredJsonGenerator jsonGenerator) {

    if (vaultNotificationConfig == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonGenerator.writeStartObject();

      if (vaultNotificationConfig.getSNSTopic() != null) {
        jsonGenerator.writeFieldName("SNSTopic").writeValue(vaultNotificationConfig.getSNSTopic());
      }

      java.util.List<String> eventsList = vaultNotificationConfig.getEvents();
      if (eventsList != null) {
        jsonGenerator.writeFieldName("Events");
        jsonGenerator.writeStartArray();
        for (String eventsListValue : eventsList) {
          if (eventsListValue != null) {
            jsonGenerator.writeValue(eventsListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<InitiateJobRequest> marshall(InitiateJobRequest initiateJobRequest) {

    if (initiateJobRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<InitiateJobRequest> request =
        new DefaultRequest<InitiateJobRequest>(initiateJobRequest, "AmazonGlacier");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "/{accountId}/vaults/{vaultName}/jobs";

    uriResourcePath =
        uriResourcePath.replace(
            "{accountId}",
            (initiateJobRequest.getAccountId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(initiateJobRequest.getAccountId()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{vaultName}",
            (initiateJobRequest.getVaultName() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(initiateJobRequest.getVaultName()), false)
                : "");
    request.setResourcePath(uriResourcePath);

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      JobParameters jobParameters = initiateJobRequest.getJobParameters();
      if (jobParameters != null) {
        jsonGenerator.writeStartObject();
        if (jobParameters.getFormat() != null) {
          jsonGenerator.writeFieldName("Format").writeValue(jobParameters.getFormat());
        }
        if (jobParameters.getType() != null) {
          jsonGenerator.writeFieldName("Type").writeValue(jobParameters.getType());
        }
        if (jobParameters.getArchiveId() != null) {
          jsonGenerator.writeFieldName("ArchiveId").writeValue(jobParameters.getArchiveId());
        }
        if (jobParameters.getDescription() != null) {
          jsonGenerator.writeFieldName("Description").writeValue(jobParameters.getDescription());
        }
        if (jobParameters.getSNSTopic() != null) {
          jsonGenerator.writeFieldName("SNSTopic").writeValue(jobParameters.getSNSTopic());
        }
        if (jobParameters.getRetrievalByteRange() != null) {
          jsonGenerator
              .writeFieldName("RetrievalByteRange")
              .writeValue(jobParameters.getRetrievalByteRange());
        }
        if (jobParameters.getInventoryRetrievalParameters() != null) {
          jsonGenerator.writeFieldName("InventoryRetrievalParameters");
          InventoryRetrievalJobInputJsonMarshaller.getInstance()
              .marshall(jobParameters.getInventoryRetrievalParameters(), jsonGenerator);
        }
        jsonGenerator.writeEndObject();
      }

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      if (!request.getHeaders().containsKey("Content-Type")) {
        request.addHeader("Content-Type", protocolFactory.getContentType());
      }
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }