com.amazonaws.Request类的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(15.7k)|赞(0)|评价(0)|浏览(238)

本文整理了Java中com.amazonaws.Request类的一些代码示例,展示了Request类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request类的具体详情如下:
包路径:com.amazonaws.Request
类名称:Request

Request介绍

[英]Represents a request being sent to an Amazon Web Service, including the parameters being sent as part of the request, the endpoint to which the request should be sent, etc.

This class is only intended for use inside the AWS client libraries and request handlers. Users of the AWS SDK for Java should not implement this interface.
[中]表示发送到Amazon Web服务的请求,包括作为请求一部分发送的参数、请求应发送到的端点等。
此类仅用于AWS客户端库和请求处理程序中。AWS SDK for Java的用户不应实现此接口。

代码示例

代码示例来源:origin: aws/aws-sdk-java

@Override
  public void beforeRequest(Request<?> request) {
    URI endpoint = request.getEndpoint();

    // If the request is using a non-standard endpoint, then
    // alter it to use the corresponding, standard endpoint
    if (nonstandardEndpointMap.containsKey(endpoint.getHost())) {
      String newHost = nonstandardEndpointMap.get(endpoint.getHost());
      String newEndpoint = endpoint.toString().replaceFirst(endpoint.getHost(), newHost);
      request.setEndpoint(URI.create(newEndpoint));
    }
  }
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Normal invoke with authentication. Credentials are required and may be overriden at the request level.
 **/
private <X, Y extends AmazonWebServiceRequest> Response<X> invoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
    ExecutionContext executionContext, URI cachedEndpoint, URI uriFromEndpointTrait) {
  executionContext.setCredentialsProvider(CredentialUtils.getCredentialsProvider(request.getOriginalRequest(), awsCredentialsProvider));
  return doInvoke(request, responseHandler, executionContext, cachedEndpoint, uriFromEndpointTrait);
}

代码示例来源:origin: aws/aws-sdk-java

@Override
  public void beforeRequest(Request<?> request) {
    request.addHandlerContext(S3HandlerContextKeys.IS_PAYLOAD_SIGNING_ENABLED, true);
    if (request.getContent() == null && request.getHttpMethod() == HttpMethodName.POST) {
      request.setContent(new ByteArrayInputStream(new byte[0]));
    }
  }
}

代码示例来源:origin: aws/aws-sdk-java

public Request<GetAccountSendingEnabledRequest> marshall(GetAccountSendingEnabledRequest getAccountSendingEnabledRequest) {
  if (getAccountSendingEnabledRequest == null) {
    throw new SdkClientException("Invalid argument passed to marshall(...)");
  }
  Request<GetAccountSendingEnabledRequest> request = new DefaultRequest<GetAccountSendingEnabledRequest>(getAccountSendingEnabledRequest,
      "AmazonSimpleEmailService");
  request.addParameter("Action", "GetAccountSendingEnabled");
  request.addParameter("Version", "2010-12-01");
  request.setHttpMethod(HttpMethodName.POST);
  return request;
}

代码示例来源:origin: aws/aws-sdk-java

@SdkInternalApi
final DescribeBackupsResult executeDescribeBackups(DescribeBackupsRequest describeBackupsRequest) {
  ExecutionContext executionContext = createExecutionContext(describeBackupsRequest);
  AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
  awsRequestMetrics.startEvent(Field.ClientExecuteTime);
  Request<DescribeBackupsRequest> request = null;
  Response<DescribeBackupsResult> response = null;
  try {
    awsRequestMetrics.startEvent(Field.RequestMarshallTime);
    try {
      request = new DescribeBackupsRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(describeBackupsRequest));
      // Binds the request metrics to the current request.
      request.setAWSRequestMetrics(awsRequestMetrics);
      request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
      request.addHandlerContext(HandlerContextKey.SERVICE_ID, "FSx");
      request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DescribeBackups");
      request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
    } finally {
      awsRequestMetrics.endEvent(Field.RequestMarshallTime);
    }
    HttpResponseHandler<AmazonWebServiceResponse<DescribeBackupsResult>> responseHandler = protocolFactory.createResponseHandler(
        new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new DescribeBackupsResultJsonUnmarshaller());
    response = invoke(request, responseHandler, executionContext);
    return response.getAwsResponse();
  } finally {
    endClientExecution(awsRequestMetrics, request, response);
  }
}

代码示例来源:origin: aws/aws-sdk-java

@Override
public GetBucketInventoryConfigurationResult getBucketInventoryConfiguration(
    GetBucketInventoryConfigurationRequest getBucketInventoryConfigurationRequest)
    throws AmazonServiceException, SdkClientException {
  getBucketInventoryConfigurationRequest = beforeClientExecution(getBucketInventoryConfigurationRequest);
  rejectNull(getBucketInventoryConfigurationRequest, "The request cannot be null");
  String bucketName = assertStringNotEmpty(getBucketInventoryConfigurationRequest.getBucketName(), "BucketName");
  String id = assertStringNotEmpty(getBucketInventoryConfigurationRequest.getId(), "Inventory id");
  Request<GetBucketInventoryConfigurationRequest> request = createRequest(bucketName, null, getBucketInventoryConfigurationRequest, HttpMethodName.GET);
  request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetBucketInventoryConfiguration");
  request.addParameter("inventory", null);
  request.addParameter("id", id);
  return invoke(request, new Unmarshallers.GetBucketInventoryConfigurationUnmarshaller(), bucketName, null);
}

代码示例来源:origin: aws/aws-sdk-java

private void runBeforeRequestHandlers() {
  AWSCredentials credentials = getCredentialsFromContext();
  request.addHandlerContext(HandlerContextKey.AWS_CREDENTIALS, credentials);
  // Apply any additional service specific request handlers that need to be run
  for (RequestHandler2 requestHandler2 : requestHandler2s) {
    // If the request handler is a type of CredentialsRequestHandler, then set the credentials in the request handler.
    if (requestHandler2 instanceof CredentialsRequestHandler) {
      ((CredentialsRequestHandler) requestHandler2).setCredentials(credentials);
    }
    requestHandler2.beforeRequest(request);
  }
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Presign a {@link SynthesizeSpeechRequest} to be vended to consumers. The expiration time of the presigned URL is {@value
 * #SYNTHESIZE_SPEECH_DEFAULT_EXPIRATION_MINUTES} from generation time.
 */
public URL getPresignedSynthesizeSpeechUrl(SynthesizeSpeechPresignRequest synthesizeSpeechPresignRequest) {
  Request<?> request = newRequest(synthesizeSpeechPresignRequest.getSigningCredentials());
  request.setEndpoint(endpoint);
  request.setResourcePath("/v1/speech");
  request.setHttpMethod(HttpMethodName.GET);
  marshallIntoRequest(synthesizeSpeechPresignRequest, request);
  Date expirationDate = synthesizeSpeechPresignRequest.getExpirationDate() == null ?
      getDefaultExpirationDate() : synthesizeSpeechPresignRequest.getExpirationDate();
  return presignerFacade.presign(request, expirationDate);
}

代码示例来源:origin: aws/aws-sdk-java

@Override
public void deleteBucketWebsiteConfiguration(DeleteBucketWebsiteConfigurationRequest deleteBucketWebsiteConfigurationRequest)
  throws SdkClientException, AmazonServiceException {
  deleteBucketWebsiteConfigurationRequest = beforeClientExecution(deleteBucketWebsiteConfigurationRequest);
  String bucketName = deleteBucketWebsiteConfigurationRequest.getBucketName();
  rejectNull(bucketName,
    "The bucket name parameter must be specified when deleting a bucket's website configuration");
  Request<DeleteBucketWebsiteConfigurationRequest> request = createRequest(bucketName, null, deleteBucketWebsiteConfigurationRequest, HttpMethodName.DELETE);
  request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DeleteBucketWebsite");
  request.addParameter("website", null);
  request.addHeader("Content-Type", "application/xml");
  invoke(request, voidResponseHandler, bucketName, null);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Marshall the {@link PutMediaRequest} to a {@link Request}.
 *
 * @param request POJO request to marshall.
 * @return Marshalled request object.
 */
private Request<PutMediaRequest> marshall(PutMediaRequest request) {
  Request<PutMediaRequest> marshalled = new PutMediaRequestProtocolMarshaller(protocolFactory).marshall(request);
  marshalled.setEndpoint(endpoint);
  marshalled.addHeader(HttpHeaderNames.TRANSFER_ENCODING.toString(), HttpHeaderValues.CHUNKED.toString());
  return marshalled;
}

代码示例来源:origin: aws/aws-sdk-java

public Request<GetDistributionRequest> marshall(GetDistributionRequest getDistributionRequest) {
  if (getDistributionRequest == null) {
    throw new SdkClientException("Invalid argument passed to marshall(...)");
  }
  Request<GetDistributionRequest> request = new DefaultRequest<GetDistributionRequest>(getDistributionRequest, "AmazonCloudFront");
  request.setHttpMethod(HttpMethodName.GET);
  String uriResourcePath = "/2018-11-05/distribution/{Id}";
  uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(uriResourcePath, "Id", getDistributionRequest.getId());
  request.setResourcePath(uriResourcePath);
  return request;
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * This method is intended for internal use only. Returns the marshaled request configured with additional
 * parameters to enable operation dry-run.
 */
@Override
public Request<AcceptVpcEndpointConnectionsRequest> getDryRunRequest() {
  Request<AcceptVpcEndpointConnectionsRequest> request = new AcceptVpcEndpointConnectionsRequestMarshaller().marshall(this);
  request.addParameter("DryRun", Boolean.toString(true));
  return request;
}

代码示例来源:origin: aws/aws-sdk-java

@SdkInternalApi
final ListTagsForResourceResult executeListTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest) {
  ExecutionContext executionContext = createExecutionContext(listTagsForResourceRequest);
  AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
  awsRequestMetrics.startEvent(Field.ClientExecuteTime);
  Request<ListTagsForResourceRequest> request = null;
  Response<ListTagsForResourceResult> response = null;
  try {
    awsRequestMetrics.startEvent(Field.RequestMarshallTime);
    try {
      request = new ListTagsForResourceRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(listTagsForResourceRequest));
      // Binds the request metrics to the current request.
      request.setAWSRequestMetrics(awsRequestMetrics);
      request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
      request.addHandlerContext(HandlerContextKey.SERVICE_ID, "FSx");
      request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListTagsForResource");
      request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
    } finally {
      awsRequestMetrics.endEvent(Field.RequestMarshallTime);
    }
    HttpResponseHandler<AmazonWebServiceResponse<ListTagsForResourceResult>> responseHandler = protocolFactory.createResponseHandler(
        new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new ListTagsForResourceResultJsonUnmarshaller());
    response = invoke(request, responseHandler, executionContext);
    return response.getAwsResponse();
  } finally {
    endClientExecution(awsRequestMetrics, request, response);
  }
}

代码示例来源:origin: aws/aws-sdk-java

@Override
public DeletePublicAccessBlockResult deletePublicAccessBlock(DeletePublicAccessBlockRequest deletePublicAccessBlockRequest) {
  deletePublicAccessBlockRequest = beforeClientExecution(deletePublicAccessBlockRequest);
  rejectNull(deletePublicAccessBlockRequest, "The request object must be specified.");
  String bucketName = deletePublicAccessBlockRequest.getBucketName();
  rejectNull(bucketName,
        "The bucket name parameter must be specified when deleting public block configuration.");
  Request<DeletePublicAccessBlockRequest> request = createRequest(bucketName, null, deletePublicAccessBlockRequest, HttpMethodName.DELETE);
  request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DeletePublicAccessBlock");
  request.addParameter("publicAccessBlock", null);
  return invoke(request, new Unmarshallers.DeletePublicAccessBlockUnmarshaller(), bucketName, null);
}

代码示例来源:origin: aws/aws-sdk-java

public Request<DescribeAdjustmentTypesRequest> marshall(DescribeAdjustmentTypesRequest describeAdjustmentTypesRequest) {
  if (describeAdjustmentTypesRequest == null) {
    throw new SdkClientException("Invalid argument passed to marshall(...)");
  }
  Request<DescribeAdjustmentTypesRequest> request = new DefaultRequest<DescribeAdjustmentTypesRequest>(describeAdjustmentTypesRequest,
      "AmazonAutoScaling");
  request.addParameter("Action", "DescribeAdjustmentTypes");
  request.addParameter("Version", "2011-01-01");
  request.setHttpMethod(HttpMethodName.POST);
  return request;
}

代码示例来源:origin: aws/aws-sdk-java

@Override
public void afterAttempt(HandlerAfterAttemptContext context) {
  ApiCallAttemptMonitoringEvent event = generateApiCallAttemptMonitoringEvent(context);
  context.getRequest().addHandlerContext(LAST_CALL_ATTEMPT, event);
  handToMonitoringListeners(event);
}

代码示例来源:origin: aws/aws-sdk-java

public Request<DeleteHostedZoneRequest> marshall(DeleteHostedZoneRequest deleteHostedZoneRequest) {
  if (deleteHostedZoneRequest == null) {
    throw new SdkClientException("Invalid argument passed to marshall(...)");
  }
  Request<DeleteHostedZoneRequest> request = new DefaultRequest<DeleteHostedZoneRequest>(deleteHostedZoneRequest, "AmazonRoute53");
  request.setHttpMethod(HttpMethodName.DELETE);
  String uriResourcePath = "/2013-04-01/hostedzone/{Id}";
  uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(uriResourcePath, "Id", deleteHostedZoneRequest.getId());
  request.setResourcePath(uriResourcePath);
  return request;
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * This method is intended for internal use only. Returns the marshaled request configured with additional
 * parameters to enable operation dry-run.
 */
@Override
public Request<AttachInternetGatewayRequest> getDryRunRequest() {
  Request<AttachInternetGatewayRequest> request = new AttachInternetGatewayRequestMarshaller().marshall(this);
  request.addParameter("DryRun", Boolean.toString(true));
  return request;
}

代码示例来源:origin: aws/aws-sdk-java

@SdkInternalApi
final TagResourceResult executeTagResource(TagResourceRequest tagResourceRequest) {
  ExecutionContext executionContext = createExecutionContext(tagResourceRequest);
  AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
  awsRequestMetrics.startEvent(Field.ClientExecuteTime);
  Request<TagResourceRequest> request = null;
  Response<TagResourceResult> response = null;
  try {
    awsRequestMetrics.startEvent(Field.RequestMarshallTime);
    try {
      request = new TagResourceRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(tagResourceRequest));
      // Binds the request metrics to the current request.
      request.setAWSRequestMetrics(awsRequestMetrics);
      request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
      request.addHandlerContext(HandlerContextKey.SERVICE_ID, "FSx");
      request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "TagResource");
      request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
    } finally {
      awsRequestMetrics.endEvent(Field.RequestMarshallTime);
    }
    HttpResponseHandler<AmazonWebServiceResponse<TagResourceResult>> responseHandler = protocolFactory.createResponseHandler(
        new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new TagResourceResultJsonUnmarshaller());
    response = invoke(request, responseHandler, executionContext);
    return response.getAwsResponse();
  } finally {
    endClientExecution(awsRequestMetrics, request, response);
  }
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Normal invoke with authentication. Credentials are required and may be overriden at the request level.
 **/
private <X, Y extends AmazonWebServiceRequest> Response<X> invoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
    ExecutionContext executionContext, URI cachedEndpoint, URI uriFromEndpointTrait) {
  executionContext.setCredentialsProvider(CredentialUtils.getCredentialsProvider(request.getOriginalRequest(), awsCredentialsProvider));
  return doInvoke(request, responseHandler, executionContext, cachedEndpoint, uriFromEndpointTrait);
}

相关文章