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;
  }
示例#2
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<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;
  }