Example usage for com.amazonaws Request getOriginalRequest

List of usage examples for com.amazonaws Request getOriginalRequest

Introduction

In this page you can find the example usage for com.amazonaws Request getOriginalRequest.

Prototype

AmazonWebServiceRequest getOriginalRequest();

Source Link

Document

Returns the original, user facing request object which this internal request object is representing.

Usage

From source file:com.github.sjones4.youcan.youare.YouAreClient.java

License:Open Source License

private <X, Y extends AmazonWebServiceRequest> Response<X> invoke(final Request<Y> request,
        final Unmarshaller<X, StaxUnmarshallerContext> unmarshaller, final ExecutionContext executionContext) {
    request.setEndpoint(endpoint);// w ww.j  a  v  a  2  s .  c om
    request.setTimeOffset(timeOffset);

    executionContext.setCredentialsProvider(
            CredentialUtils.getCredentialsProvider(request.getOriginalRequest(), awsCredentialsProvider));

    StaxResponseHandler<X> responseHandler = new StaxResponseHandler<X>(unmarshaller);
    DefaultErrorResponseHandler errorResponseHandler = new DefaultErrorResponseHandler(exceptionUnmarshallers);
    return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}

From source file:com.ivona.services.tts.IvonaSpeechCloudClient.java

License:Open Source License

private <Y> Request<Y> prepareRequest(Request<Y> request, ExecutionContext executionContext,
        boolean signRequest) {
    request.setEndpoint(endpoint);/*w ww  .  jav  a 2 s. c  o m*/
    request.setTimeOffset(timeOffset);

    AWSCredentials credentials = awsCredentialsProvider.getCredentials();

    AmazonWebServiceRequest originalRequest = request.getOriginalRequest();
    if (originalRequest != null && originalRequest.getRequestCredentials() != null) {
        credentials = originalRequest.getRequestCredentials();
    }
    if (signRequest) {
        // expiration date is not currently supported on service side, but presignRequest method requires
        // this argument so one with default value is provided.
        Date expirationDate = DateTime.now(DateTimeZone.UTC).plusMinutes(DEFAULT_GET_REQUEST_EXPIRATION_MINUTES)
                .toDate();
        signer.presignRequest(request, credentials, expirationDate);
    } else {
        executionContext.setSigner(signer);
        executionContext.setCredentials(credentials);
    }
    return request;
}

From source file:com.netflix.spectator.aws.SpectatorRequestMetricCollector.java

License:Apache License

private Map<String, String> getAllTags(Request<?> request) {
    final AWSRequestMetrics metrics = request.getAWSRequestMetrics();
    final Map<String, String> allTags = new HashMap<>();
    for (TagField tag : TAGS) {
        allTags.put(tag.getName(), tag.getValue(metrics).orElse(UNKNOWN));
    }//from w  w w. jav a 2 s.c om
    allTags.put(TAG_REQUEST_TYPE, request.getOriginalRequest().getClass().getSimpleName());
    final boolean error = isError(metrics);
    if (error) {
        for (TagField tag : ERRORS) {
            allTags.put(tag.getName(), tag.getValue(metrics).orElse(UNKNOWN));
        }
    }
    allTags.put(TAG_ERROR, Boolean.toString(error));
    allTags.putAll(customTags);
    return Collections.unmodifiableMap(allTags);
}

From source file:io.opentracing.contrib.aws.TracingRequestHandler.java

License:Apache License

/**
 * {@inheritDoc}//from   w  ww.ja  v a2  s  .  com
 */
@Override
public void beforeRequest(Request<?> request) {
    Tracer.SpanBuilder spanBuilder = tracer.buildSpan(request.getOriginalRequest().getClass().getSimpleName())
            .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);

    if (parentContext != null) {
        spanBuilder.asChildOf(parentContext);
    }

    Span span = spanBuilder.start();
    SpanDecorator.onRequest(request, span);

    tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new TextMapAdapter(request.getHeaders()));

    request.addHandlerContext(contextKey, span);
}