public Request<GetExportRequest> marshall(GetExportRequest getExportRequest) {

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

    Request<GetExportRequest> request =
        new DefaultRequest<GetExportRequest>(getExportRequest, "AmazonApiGateway");

    request.setHttpMethod(HttpMethodName.GET);

    if (getExportRequest.getAccepts() != null) {
      request.addHeader("Accept", StringUtils.fromString(getExportRequest.getAccepts()));
    }

    String uriResourcePath = "/restapis/{restapi_id}/stages/{stage_name}/exports/{export_type}";

    uriResourcePath =
        uriResourcePath.replace(
            "{restapi_id}",
            (getExportRequest.getRestApiId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(getExportRequest.getRestApiId()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{stage_name}",
            (getExportRequest.getStageName() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(getExportRequest.getStageName()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{export_type}",
            (getExportRequest.getExportType() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(getExportRequest.getExportType()), false)
                : "");
    request.setResourcePath(uriResourcePath);

    java.util.Map<String, String> parameters = getExportRequest.getParameters();
    if (parameters != null) {
      for (Map.Entry<String, String> entry : parameters.entrySet()) {
        if (entry.getValue() != null) {
          request.addParameter(
              StringUtils.fromString(entry.getKey()), StringUtils.fromString(entry.getValue()));
        }
      }
    }

    request.setContent(new ByteArrayInputStream(new byte[0]));
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", DEFAULT_CONTENT_TYPE);
    }

    return request;
  }
  public Request<DeleteMethodResponseRequest> marshall(
      DeleteMethodResponseRequest deleteMethodResponseRequest) {

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

    Request<DeleteMethodResponseRequest> request =
        new DefaultRequest<DeleteMethodResponseRequest>(
            deleteMethodResponseRequest, "AmazonApiGateway");

    request.setHttpMethod(HttpMethodName.DELETE);

    String uriResourcePath =
        "/restapis/{restapi_id}/resources/{resource_id}/methods/{http_method}/responses/{status_code}";

    uriResourcePath =
        uriResourcePath.replace(
            "{restapi_id}",
            (deleteMethodResponseRequest.getRestApiId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(deleteMethodResponseRequest.getRestApiId()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{resource_id}",
            (deleteMethodResponseRequest.getResourceId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(deleteMethodResponseRequest.getResourceId()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{http_method}",
            (deleteMethodResponseRequest.getHttpMethod() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(deleteMethodResponseRequest.getHttpMethod()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{status_code}",
            (deleteMethodResponseRequest.getStatusCode() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(deleteMethodResponseRequest.getStatusCode()), false)
                : "");
    request.setResourcePath(uriResourcePath);

    request.setContent(new ByteArrayInputStream(new byte[0]));
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", protocolFactory.getContentType());
    }

    return request;
  }
  public Request<GetThingShadowRequest> marshall(GetThingShadowRequest getThingShadowRequest) {

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

    Request<GetThingShadowRequest> request =
        new DefaultRequest<GetThingShadowRequest>(getThingShadowRequest, "AWSIotData");

    request.setHttpMethod(HttpMethodName.GET);

    String uriResourcePath = "/things/{thingName}/shadow";

    uriResourcePath =
        uriResourcePath.replace(
            "{thingName}",
            (getThingShadowRequest.getThingName() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(getThingShadowRequest.getThingName()), false)
                : "");
    request.setResourcePath(uriResourcePath);

    request.setContent(new ByteArrayInputStream(new byte[0]));
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", protocolFactory.getContentType());
    }

    return request;
  }
  public Request<UpdateHostedZoneCommentRequest> marshall(
      UpdateHostedZoneCommentRequest updateHostedZoneCommentRequest) {

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

    Request<UpdateHostedZoneCommentRequest> request =
        new DefaultRequest<UpdateHostedZoneCommentRequest>(
            updateHostedZoneCommentRequest, "AmazonRoute53");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "/2013-04-01/hostedzone/{Id}";

    uriResourcePath =
        uriResourcePath.replace(
            "{Id}",
            (updateHostedZoneCommentRequest.getId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(updateHostedZoneCommentRequest.getId()), false)
                : "");
    request.setResourcePath(uriResourcePath);

    try {
      StringWriter stringWriter = new StringWriter();
      XMLWriter xmlWriter =
          new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/");

      xmlWriter.startElement("UpdateHostedZoneCommentRequest");
      if (updateHostedZoneCommentRequest != null) {

        if (updateHostedZoneCommentRequest.getComment() != null) {
          xmlWriter
              .startElement("Comment")
              .value(updateHostedZoneCommentRequest.getComment())
              .endElement();
        }
      }
      xmlWriter.endElement();

      request.setContent(new StringInputStream(stringWriter.getBuffer().toString()));
      request.addHeader(
          "Content-Length",
          Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length));
      if (!request.getHeaders().containsKey("Content-Type")) {
        request.addHeader("Content-Type", "application/xml");
      }
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to XML: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<DeleteDeploymentRequest> marshall(
      DeleteDeploymentRequest deleteDeploymentRequest) {

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

    Request<DeleteDeploymentRequest> request =
        new DefaultRequest<DeleteDeploymentRequest>(deleteDeploymentRequest, "AmazonApiGateway");

    request.setHttpMethod(HttpMethodName.DELETE);

    String uriResourcePath = "/restapis/{restapi_id}/deployments/{deployment_id}";

    uriResourcePath =
        uriResourcePath.replace(
            "{restapi_id}",
            (deleteDeploymentRequest.getRestApiId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(deleteDeploymentRequest.getRestApiId()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{deployment_id}",
            (deleteDeploymentRequest.getDeploymentId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(deleteDeploymentRequest.getDeploymentId()), false)
                : "");
    request.setResourcePath(uriResourcePath);

    request.setContent(new ByteArrayInputStream(new byte[0]));
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", DEFAULT_CONTENT_TYPE);
    }

    return request;
  }
  public Request<AcceptCertificateTransferRequest> marshall(
      AcceptCertificateTransferRequest acceptCertificateTransferRequest) {

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

    Request<AcceptCertificateTransferRequest> request =
        new DefaultRequest<AcceptCertificateTransferRequest>(
            acceptCertificateTransferRequest, "AWSIot");

    request.setHttpMethod(HttpMethodName.PATCH);

    String uriResourcePath = "/accept-certificate-transfer/{certificateId}";

    uriResourcePath =
        uriResourcePath.replace(
            "{certificateId}",
            (acceptCertificateTransferRequest.getCertificateId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(acceptCertificateTransferRequest.getCertificateId()),
                    false)
                : "");
    request.setResourcePath(uriResourcePath);

    if (acceptCertificateTransferRequest.getSetAsActive() != null) {
      request.addParameter(
          "setAsActive",
          StringUtils.fromBoolean(acceptCertificateTransferRequest.getSetAsActive()));
    }

    request.setContent(new ByteArrayInputStream(new byte[0]));
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", protocolFactory.getContentType());
    }

    return request;
  }
Exemplo n.º 7
0
  public Request<GetDeploymentsRequest> marshall(GetDeploymentsRequest getDeploymentsRequest) {

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

    Request<GetDeploymentsRequest> request =
        new DefaultRequest<GetDeploymentsRequest>(getDeploymentsRequest, "AmazonApiGateway");

    request.setHttpMethod(HttpMethodName.GET);

    String uriResourcePath = "/restapis/{restapi_id}/deployments";

    uriResourcePath =
        uriResourcePath.replace(
            "{restapi_id}",
            (getDeploymentsRequest.getRestApiId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(getDeploymentsRequest.getRestApiId()), false)
                : "");
    request.setResourcePath(uriResourcePath);

    if (getDeploymentsRequest.getPosition() != null) {
      request.addParameter("position", StringUtils.fromString(getDeploymentsRequest.getPosition()));
    }

    if (getDeploymentsRequest.getLimit() != null) {
      request.addParameter("limit", StringUtils.fromInteger(getDeploymentsRequest.getLimit()));
    }

    request.setContent(new ByteArrayInputStream(new byte[0]));
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", protocolFactory.getContentType());
    }

    return request;
  }
  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;
  }
  public Request<UpdateMethodResponseRequest> marshall(
      UpdateMethodResponseRequest updateMethodResponseRequest) {

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

    Request<UpdateMethodResponseRequest> request =
        new DefaultRequest<UpdateMethodResponseRequest>(
            updateMethodResponseRequest, "AmazonApiGateway");

    request.setHttpMethod(HttpMethodName.PATCH);

    String uriResourcePath =
        "/restapis/{restapi_id}/resources/{resource_id}/methods/{http_method}/responses/{status_code}";

    uriResourcePath =
        uriResourcePath.replace(
            "{restapi_id}",
            (updateMethodResponseRequest.getRestApiId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(updateMethodResponseRequest.getRestApiId()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{resource_id}",
            (updateMethodResponseRequest.getResourceId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(updateMethodResponseRequest.getResourceId()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{http_method}",
            (updateMethodResponseRequest.getHttpMethod() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(updateMethodResponseRequest.getHttpMethod()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{status_code}",
            (updateMethodResponseRequest.getStatusCode() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(updateMethodResponseRequest.getStatusCode()), false)
                : "");
    request.setResourcePath(uriResourcePath);

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

      java.util.List<PatchOperation> patchOperationsList =
          updateMethodResponseRequest.getPatchOperations();
      if (patchOperationsList != null) {
        jsonGenerator.writeFieldName("patchOperations");
        jsonGenerator.writeStartArray();
        for (PatchOperation patchOperationsListValue : patchOperationsList) {
          if (patchOperationsListValue != null) {

            PatchOperationJsonMarshaller.getInstance()
                .marshall(patchOperationsListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

      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;
  }