software.amazon.awssdk.awscore.AwsRequest Java Examples
The following examples show how to use
software.amazon.awssdk.awscore.AwsRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AwsScanner.java From clouditor with Apache License 2.0 | 6 votes |
<O extends AwsResponse, R extends AwsRequest, S> void enrichSimple( Asset asset, String key, Function<R, O> function, Function<O, S> valueFunction, R builder) { try { var response = function.apply(builder); asset.setProperty(key, valueFunction.apply(response)); } catch (AwsServiceException ex) { // ignore if error is 404, since this just means that the value is empty if (ex.awsErrorDetails().sdkHttpResponse().statusCode() != 404) { LOGGER.info( "Got exception from {} while retrieving info for {}: {}", this.getClass(), key, ex.getMessage()); } } }
Example #2
Source File: AwsScanner.java From clouditor with Apache License 2.0 | 6 votes |
<O extends AwsResponse, R extends AwsRequest, S extends ToCopyableBuilder> void enrich( AssetProperties properties, String key, Function<R, O> listFunction, Function<O, S> valueFunction, R builder) { try { var response = listFunction.apply(builder); properties.put( key, MAPPER.convertValue(valueFunction.apply(response).toBuilder(), AssetProperties.class)); } catch (AwsServiceException ex) { // ignore if error is 404, since this just means that the value is empty if (ex.statusCode() != 404) { LOGGER.info( "Got exception from {} while retrieving info for {}: {}", this.getClass(), key, ex.getMessage()); } } }
Example #3
Source File: AwsServiceBaseRequestSpec.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Override public TypeSpec poetSpec() { TypeSpec.Builder builder = TypeSpec.classBuilder(className()) .addAnnotation(PoetUtils.generatedAnnotation()) .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT) .superclass(ClassName.get(AwsRequest.class)) .addMethod(MethodSpec.constructorBuilder() .addModifiers(Modifier.PROTECTED) .addParameter(className().nestedClass("Builder"), "builder") .addStatement("super(builder)") .build()) .addMethod(MethodSpec.methodBuilder("toBuilder") .addAnnotation(Override.class) .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT) .returns(className().nestedClass("Builder")) .build()) .addType(builderInterfaceSpec()) .addType(builderImplSpec()); return builder.build(); }
Example #4
Source File: AmazonWebServicesClientProxy.java From cloudformation-cli-java-plugin with Apache License 2.0 | 6 votes |
public <RequestT extends AwsRequest, ResultT extends AwsResponse> ResponseBytes<ResultT> injectCredentialsAndInvokeV2Bytes(final RequestT request, final Function<RequestT, ResponseBytes<ResultT>> requestFunction) { AwsRequestOverrideConfiguration overrideConfiguration = AwsRequestOverrideConfiguration.builder() .credentialsProvider(v2CredentialsProvider).build(); @SuppressWarnings("unchecked") RequestT wrappedRequest = (RequestT) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); try { ResponseBytes<ResultT> response = requestFunction.apply(wrappedRequest); logRequestMetadataV2(request, response.response()); return response; } catch (final Throwable e) { loggerProxy.log(String.format("Failed to execute remote function: {%s}", e.getMessage())); throw e; } }
Example #5
Source File: AmazonWebServicesClientProxy.java From cloudformation-cli-java-plugin with Apache License 2.0 | 6 votes |
public <RequestT extends AwsRequest, ResultT extends AwsResponse> ResponseInputStream<ResultT> injectCredentialsAndInvokeV2InputStream(final RequestT request, final Function<RequestT, ResponseInputStream<ResultT>> requestFunction) { AwsRequestOverrideConfiguration overrideConfiguration = AwsRequestOverrideConfiguration.builder() .credentialsProvider(v2CredentialsProvider).build(); @SuppressWarnings("unchecked") RequestT wrappedRequest = (RequestT) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); try { ResponseInputStream<ResultT> response = requestFunction.apply(wrappedRequest); logRequestMetadataV2(request, response.response()); return response; } catch (final Throwable e) { loggerProxy.log(String.format("Failed to execute remote function: {%s}", e.getMessage())); throw e; } }
Example #6
Source File: AmazonWebServicesClientProxy.java From cloudformation-cli-java-plugin with Apache License 2.0 | 6 votes |
public <RequestT extends AwsRequest, ResultT extends AwsResponse, IterableT extends SdkIterable<ResultT>> IterableT injectCredentialsAndInvokeIterableV2(final RequestT request, final Function<RequestT, IterableT> requestFunction) { AwsRequestOverrideConfiguration overrideConfiguration = AwsRequestOverrideConfiguration.builder() .credentialsProvider(v2CredentialsProvider).build(); @SuppressWarnings("unchecked") RequestT wrappedRequest = (RequestT) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); try { IterableT response = requestFunction.apply(wrappedRequest); response.forEach(r -> logRequestMetadataV2(request, r)); return response; } catch (final Throwable e) { loggerProxy.log(String.format("Failed to execute remote function: {%s}", e.getMessage())); throw e; } }
Example #7
Source File: AmazonWebServicesClientProxy.java From cloudformation-cli-java-plugin with Apache License 2.0 | 6 votes |
public <RequestT extends AwsRequest, ResultT extends AwsResponse> CompletableFuture<ResultT> injectCredentialsAndInvokeV2Async(final RequestT request, final Function<RequestT, CompletableFuture<ResultT>> requestFunction) { AwsRequestOverrideConfiguration overrideConfiguration = AwsRequestOverrideConfiguration.builder() .credentialsProvider(v2CredentialsProvider).build(); @SuppressWarnings("unchecked") RequestT wrappedRequest = (RequestT) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); try { CompletableFuture<ResultT> response = requestFunction.apply(wrappedRequest).thenApplyAsync(resultT -> { logRequestMetadataV2(request, resultT); return resultT; }); return response; } catch (final Throwable e) { loggerProxy.log(String.format("Failed to execute remote function: {%s}", e.getMessage())); throw e; } }
Example #8
Source File: AmazonWebServicesClientProxy.java From cloudformation-cli-java-plugin with Apache License 2.0 | 6 votes |
public <RequestT extends AwsRequest, ResultT extends AwsResponse> ResultT injectCredentialsAndInvokeV2(final RequestT request, final Function<RequestT, ResultT> requestFunction) { AwsRequestOverrideConfiguration overrideConfiguration = AwsRequestOverrideConfiguration.builder() .credentialsProvider(v2CredentialsProvider).build(); @SuppressWarnings("unchecked") RequestT wrappedRequest = (RequestT) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); try { ResultT response = requestFunction.apply(wrappedRequest); logRequestMetadataV2(request, response); return response; } catch (final Throwable e) { loggerProxy.log(String.format("Failed to execute remote function: {%s}", e.getMessage())); throw e; } }
Example #9
Source File: AwsScanner.java From clouditor with Apache License 2.0 | 5 votes |
<O extends AwsResponse, R extends AwsRequest, S extends ToCopyableBuilder> void enrich( Asset asset, String key, Function<R, O> listFunction, Function<O, S> valueFunction, R builder) { this.enrich(asset.getProperties(), key, listFunction, valueFunction, builder); }
Example #10
Source File: KinesisRequestsBuilder.java From amazon-kinesis-client with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private static <T extends AwsRequest.Builder> T appendUserAgent(final T builder) { return (T) builder .overrideConfiguration( AwsRequestOverrideConfiguration.builder() .addApiName(ApiName.builder().name(RetrievalConfig.KINESIS_CLIENT_LIB_USER_AGENT) .version(RetrievalConfig.KINESIS_CLIENT_LIB_USER_AGENT_VERSION).build()) .build()); }
Example #11
Source File: AwsServiceBaseRequestSpec.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private TypeSpec builderImplSpec() { return TypeSpec.classBuilder("BuilderImpl") .addModifiers(Modifier.PROTECTED, Modifier.STATIC, Modifier.ABSTRACT) .addSuperinterface(className().nestedClass("Builder")) .superclass(ClassName.get(AwsRequest.class).nestedClass("BuilderImpl")) .addMethod(MethodSpec.constructorBuilder() .addModifiers(Modifier.PROTECTED) .build()) .addMethod(MethodSpec.constructorBuilder() .addModifiers(Modifier.PROTECTED) .addParameter(className(), "request") .addStatement("super(request)") .build()) .build(); }
Example #12
Source File: AwsServiceBaseRequestSpec.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private TypeSpec builderInterfaceSpec() { return TypeSpec.interfaceBuilder("Builder") .addModifiers(Modifier.PUBLIC) .addSuperinterface(ClassName.get(AwsRequest.class).nestedClass("Builder")) .addMethod(MethodSpec.methodBuilder("build") .addAnnotation(Override.class) .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT) .returns(className()) .build()) .build(); }
Example #13
Source File: AmazonWebServicesClientProxy.java From cloudformation-cli-java-plugin with Apache License 2.0 | 5 votes |
private <RequestT extends AwsRequest, ResultT extends AwsResponse> void logRequestMetadataV2(final RequestT request, final ResultT response) { try { String requestName = request.getClass().getSimpleName(); String requestId = (response == null || response.responseMetadata() == null) ? "" : response.responseMetadata().requestId(); loggerProxy .log(String.format("{\"apiRequest\": {\"requestId\": \"%s\", \"requestName\": \"%s\"}}", requestId, requestName)); } catch (final Exception e) { loggerProxy.log(e.getMessage()); } }
Example #14
Source File: Translator.java From cloudformation-cli-java-plugin with Apache License 2.0 | 5 votes |
/** * Request to list resources * @param nextToken token passed to the aws service list resources request * @return awsRequest the aws service request to list resources within aws account */ static AwsRequest translateToListRequest(final String nextToken) { final AwsRequest awsRequest = null; // TODO: construct a request // e.g. https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs/blob/2077c92299aeb9a68ae8f4418b5e932b12a8b186/aws-logs-loggroup/src/main/java/com/aws/logs/loggroup/Translator.java#L26-L31 return awsRequest; }
Example #15
Source File: Translator.java From cloudformation-cli-java-plugin with Apache License 2.0 | 5 votes |
/** * Request to update properties of a previously created resource * @param model resource model * @return awsRequest the aws service request to modify a resource */ static AwsRequest translateToFirstUpdateRequest(final ResourceModel model) { final AwsRequest awsRequest = null; // TODO: construct a request // e.g. https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs/blob/2077c92299aeb9a68ae8f4418b5e932b12a8b186/aws-logs-loggroup/src/main/java/com/aws/logs/loggroup/Translator.java#L45-L50 return awsRequest; }
Example #16
Source File: Translator.java From cloudformation-cli-java-plugin with Apache License 2.0 | 5 votes |
/** * Request to delete a resource * @param model resource model * @return awsRequest the aws service request to delete a resource */ static AwsRequest translateToDeleteRequest(final ResourceModel model) { final AwsRequest awsRequest = null; // TODO: construct a request // e.g. https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs/blob/2077c92299aeb9a68ae8f4418b5e932b12a8b186/aws-logs-loggroup/src/main/java/com/aws/logs/loggroup/Translator.java#L33-L37 return awsRequest; }
Example #17
Source File: Translator.java From cloudformation-cli-java-plugin with Apache License 2.0 | 5 votes |
/** * Request to read a resource * @param model resource model * @return awsRequest the aws service request to describe a resource */ static AwsRequest translateToReadRequest(final ResourceModel model) { final AwsRequest awsRequest = null; // TODO: construct a request // e.g. https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs/blob/2077c92299aeb9a68ae8f4418b5e932b12a8b186/aws-logs-loggroup/src/main/java/com/aws/logs/loggroup/Translator.java#L20-L24 return awsRequest; }
Example #18
Source File: Translator.java From cloudformation-cli-java-plugin with Apache License 2.0 | 5 votes |
/** * Request to create a resource * @param model resource model * @return awsRequest the aws service request to create a resource */ static AwsRequest translateToCreateRequest(final ResourceModel model) { final AwsRequest awsRequest = null; // TODO: construct a request // e.g. https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs/blob/2077c92299aeb9a68ae8f4418b5e932b12a8b186/aws-logs-loggroup/src/main/java/com/aws/logs/loggroup/Translator.java#L39-L43 return awsRequest; }
Example #19
Source File: AwsScanner.java From clouditor with Apache License 2.0 | 5 votes |
<O extends AwsResponse, R extends AwsRequest, S extends ToCopyableBuilder> void enrichList( Asset asset, String key, Function<R, O> listFunction, Function<O, List<S>> valueFunction, R builder) { try { var response = listFunction.apply(builder); var list = valueFunction.apply(response); asset.setProperty( key, list.stream() .map(x -> MAPPER.convertValue(x.toBuilder(), AssetProperties.class)) .collect(Collectors.toList())); } catch (AwsServiceException ex) { // ignore if error is 404, since this just means that the value is empty if (ex.statusCode() != 404) { LOGGER.info( "Got exception from {} while retrieving info for {}: {}", this.getClass(), key, ex.getMessage()); } } }
Example #20
Source File: Translator.java From cloudformation-cli-java-plugin with Apache License 2.0 | 4 votes |
/** * Request to update some other properties that could not be provisioned through first update request * @param model resource model * @return awsRequest the aws service request to modify a resource */ static AwsRequest translateToSecondUpdateRequest(final ResourceModel model) { final AwsRequest awsRequest = null; // TODO: construct a request return awsRequest; }
Example #21
Source File: ProxyClient.java From cloudformation-cli-java-plugin with Apache License 2.0 | 3 votes |
/** * This is a synchronous version of making API calls which implement * ResponseInputStream in the SDKv2 * * @param request, the AWS service request that we need to make * @param requestFunction, this is a Lambda closure that provide the actual API * that needs to be invoked. * @param <RequestT> the request type * @param <ResponseT> the response from the request * @return the response if successful. Else it will propagate all * {@link software.amazon.awssdk.awscore.exception.AwsServiceException} * that is thrown or * {@link software.amazon.awssdk.core.exception.SdkClientException} if * there is client side problem */ default <RequestT extends AwsRequest, ResponseT extends AwsResponse> ResponseInputStream<ResponseT> injectCredentialsAndInvokeV2InputStream(RequestT request, Function<RequestT, ResponseInputStream<ResponseT>> requestFunction) { throw new UnsupportedOperationException(); }
Example #22
Source File: ProxyClient.java From cloudformation-cli-java-plugin with Apache License 2.0 | 2 votes |
/** * This is a synchronous version of making API calls which implement * ResponseBytes in the SDKv2 * * @param request, the AWS service request that we need to make * @param requestFunction, this is a Lambda closure that provide the actual API * that needs to be invoked. * @param <RequestT> the request type * @param <ResponseT> the response from the request * @return the response if successful. Else it will propagate all * {@link software.amazon.awssdk.awscore.exception.AwsServiceException} * that is thrown or * {@link software.amazon.awssdk.core.exception.SdkClientException} if * there is client side problem */ default <RequestT extends AwsRequest, ResponseT extends AwsResponse> ResponseBytes<ResponseT> injectCredentialsAndInvokeV2Bytes(RequestT request, Function<RequestT, ResponseBytes<ResponseT>> requestFunction) { throw new UnsupportedOperationException(); }
Example #23
Source File: ProxyClient.java From cloudformation-cli-java-plugin with Apache License 2.0 | 2 votes |
/** * This is a synchronous version of making API calls which implement Iterable in * the SDKv2 * * @param request, the AWS service request that we need to make * @param requestFunction, this is a Lambda closure that provide the actual API * that needs to be invoked. * @param <RequestT> the request type * @param <ResponseT> the response from the request * @param <IterableT> the iterable collection from the response * @return the response if successful. Else it will propagate all * {@link software.amazon.awssdk.awscore.exception.AwsServiceException} * that is thrown or * {@link software.amazon.awssdk.core.exception.SdkClientException} if * there is client side problem */ default <RequestT extends AwsRequest, ResponseT extends AwsResponse, IterableT extends SdkIterable<ResponseT>> IterableT injectCredentialsAndInvokeIterableV2(RequestT request, Function<RequestT, IterableT> requestFunction) { throw new UnsupportedOperationException(); }
Example #24
Source File: ProxyClient.java From cloudformation-cli-java-plugin with Apache License 2.0 | 2 votes |
/** * This is the asynchronous version of making API calls. * * @param request, the AWS service request that we need to make * @param requestFunction, this is a Lambda closure that provide the actual API * that needs to be invoked. * @param <RequestT> the request type * @param <ResponseT> the response from the request * @return the response if successful. Else it will propagate all * {@link software.amazon.awssdk.awscore.exception.AwsServiceException} * that is thrown or * {@link software.amazon.awssdk.core.exception.SdkClientException} if * there is client side problem */ default <RequestT extends AwsRequest, ResponseT extends AwsResponse> CompletableFuture<ResponseT> injectCredentialsAndInvokeV2Async(RequestT request, Function<RequestT, CompletableFuture<ResponseT>> requestFunction) { throw new UnsupportedOperationException(); }
Example #25
Source File: ProxyClient.java From cloudformation-cli-java-plugin with Apache License 2.0 | 2 votes |
/** * This is the synchronous version of making API calls. * * @param request, the AWS service request that we need to make * @param requestFunction, this is a Lambda closure that provide the actual API * that needs to be invoked. * @param <RequestT> the request type * @param <ResponseT> the response from the request * @return the response if successful. Else it will propagate all * {@link software.amazon.awssdk.awscore.exception.AwsServiceException} * that is thrown or * {@link software.amazon.awssdk.core.exception.SdkClientException} if * there is client side problem * */ <RequestT extends AwsRequest, ResponseT extends AwsResponse> ResponseT injectCredentialsAndInvokeV2(RequestT request, Function<RequestT, ResponseT> requestFunction);