Example usage for com.amazonaws Request setTimeOffset

List of usage examples for com.amazonaws Request setTimeOffset

Introduction

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

Prototype

void setTimeOffset(int timeOffset);

Source Link

Document

Sets the optional value for time offset for this request.

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 w w .  j a va 2s.co m*/
    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);//from  w w  w .ja  v a 2 s. c om
    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;
}