software.amazon.awssdk.awscore.client.builder.AwsClientBuilder Java Examples
The following examples show how to use
software.amazon.awssdk.awscore.client.builder.AwsClientBuilder.
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: AwsScannerTest.java From clouditor with Apache License 2.0 | 6 votes |
static <B extends SdkClient, C extends AwsClientBuilder<C, B>, T extends ToCopyableBuilder> void discoverAssets( Class<B> apiClass, Supplier<AwsScanner<B, C, T>> supplier, Consumer<B> configurator) { var scanner = supplier.get(); System.setProperty("aws.region", "mock"); System.setProperty("aws.accessKeyId", "mock"); System.setProperty("aws.secretAccessKey", "mock"); // mock the client var api = mock(apiClass); // scanner.init(); don't init scanner.setInitialized(true); configurator.accept(api); // force the api scanner.setApi(api); assets = scanner.scan(null); }
Example #2
Source File: S3FileSystem.java From dremio-oss with Apache License 2.0 | 6 votes |
private <T extends AwsClientBuilder<?,?>> T configClientBuilder(T builder, String bucket) { final Configuration conf = getConf(); // Note that AWS SDKv2 client will close the credentials provider if needed when the client is closed builder.credentialsProvider(getAsync2Provider(conf)); Optional<String> endpoint = getEndpoint(conf); endpoint.ifPresent(e -> { try { builder.endpointOverride(new URI(e)); } catch (URISyntaxException use) { throw UserException.sourceInBadState(use).build(logger); } }); if (!isCompatMode()) { // normal s3/govcloud mode. builder.region(getAWSBucketRegion(bucket)); } else { builder.region(getAWSRegionFromConfigurationOrDefault(conf)); } return builder; }
Example #3
Source File: BaseClientBuilderInterface.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Override public TypeSpec poetSpec() { TypeSpec.Builder builder = PoetUtils.createInterfaceBuilder(builderInterfaceName) .addTypeVariable(PoetUtils.createBoundedTypeVariableName("B", builderInterfaceName, "B", "C")) .addTypeVariable(TypeVariableName.get("C")) .addSuperinterface(PoetUtils.createParameterizedTypeName(AwsClientBuilder.class, "B", "C")) .addJavadoc(getJavadoc()); if (model.getEndpointOperation().isPresent()) { if (model.getCustomizationConfig().isEnableEndpointDiscoveryMethodRequired()) { builder.addMethod(enableEndpointDiscovery()); } builder.addMethod(endpointDiscovery()); } if (model.getCustomizationConfig().getServiceSpecificClientConfigClass() != null) { builder.addMethod(serviceConfigurationMethod()); builder.addMethod(serviceConfigurationConsumerBuilderMethod()); } return builder.build(); }
Example #4
Source File: AmazonClientRecorder.java From quarkus with Apache License 2.0 | 6 votes |
public void initAwsClient(AwsClientBuilder builder, String extension, AwsConfig config) { config.region.ifPresent(builder::region); if (config.credentials.type == AwsCredentialsProviderType.STATIC) { if (!config.credentials.staticProvider.accessKeyId.isPresent() || !config.credentials.staticProvider.secretAccessKey.isPresent()) { throw new RuntimeConfigurationError( String.format("quarkus.%s.aws.credentials.static-provider.access-key-id and " + "quarkus.%s.aws.credentials.static-provider.secret-access-key cannot be empty if STATIC credentials provider used.", extension, extension)); } } if (config.credentials.type == AwsCredentialsProviderType.PROCESS) { if (!config.credentials.processProvider.command.isPresent()) { throw new RuntimeConfigurationError( String.format( "quarkus.%s.aws.credentials.process-provider.command cannot be empty if PROCESS credentials provider used.", extension)); } } builder.credentialsProvider(config.credentials.type.create(config.credentials)); }
Example #5
Source File: AbstractAmazonServiceProcessor.java From quarkus with Apache License 2.0 | 6 votes |
protected void initClientBuilders(List<AmazonClientBuilderBuildItem> clients, AmazonClientRecorder recorder, RuntimeValue<AwsConfig> awsConfigRuntime, RuntimeValue<SdkConfig> sdkConfigRuntime, SdkBuildTimeConfig sdkBuildConfig, BuildProducer<AmazonClientBuilderConfiguredBuildItem> producer) { Optional<AmazonClientBuilderBuildItem> matchingClientBuilderBuildItem = clients.stream() .filter(c -> c.getAwsClientName().equals(configName())) .findAny(); matchingClientBuilderBuildItem.ifPresent(client -> { RuntimeValue<? extends AwsClientBuilder> syncBuilder = null; RuntimeValue<? extends AwsClientBuilder> asyncBuilder = null; if (client.getSyncBuilder() != null) { syncBuilder = recorder.configure(client.getSyncBuilder(), awsConfigRuntime, sdkConfigRuntime, sdkBuildConfig, configName()); } if (client.getAsyncBuilder() != null) { asyncBuilder = recorder.configure(client.getAsyncBuilder(), awsConfigRuntime, sdkConfigRuntime, sdkBuildConfig, configName()); } producer.produce(new AmazonClientBuilderConfiguredBuildItem(configName(), syncBuilder, asyncBuilder)); }); }
Example #6
Source File: AbstractAmazonServiceProcessor.java From quarkus with Apache License 2.0 | 6 votes |
protected void createClientBuilders(List<AmazonClientTransportsBuildItem> clients, BuildProducer<AmazonClientBuilderBuildItem> builderProducer, Function<RuntimeValue<SdkHttpClient.Builder>, RuntimeValue<AwsClientBuilder>> syncFunc, Function<RuntimeValue<SdkAsyncHttpClient.Builder>, RuntimeValue<AwsClientBuilder>> asyncFunc) { for (AmazonClientTransportsBuildItem client : clients) { if (configName().equals(client.getAwsClientName())) { RuntimeValue<AwsClientBuilder> syncBuilder = null; RuntimeValue<AwsClientBuilder> asyncBuilder = null; if (client.getSyncClassName().isPresent()) { syncBuilder = syncFunc.apply(client.getSyncTransport()); } if (client.getAsyncClassName().isPresent()) { asyncBuilder = asyncFunc.apply(client.getAsyncTransport()); } builderProducer.produce(new AmazonClientBuilderBuildItem(client.getAwsClientName(), syncBuilder, asyncBuilder)); } } }
Example #7
Source File: S3Recorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<AwsClientBuilder> createAsyncBuilder(S3Config config, RuntimeValue<SdkAsyncHttpClient.Builder> transport) { S3AsyncClientBuilder builder = S3AsyncClient.builder(); configureS3Client(builder, config); if (transport != null) { builder.httpClientBuilder(transport.getValue()); } return new RuntimeValue<>(builder); }
Example #8
Source File: AwsScanner.java From clouditor with Apache License 2.0 | 5 votes |
public AwsScanner( Supplier<AwsClientBuilder<B, C>> builderSupplier, Function<T, String> idGenerator, Function<T, String> nameGenerator) { super(null, idGenerator, nameGenerator); this.builderSupplier = builderSupplier; this.postProcessor = ToCopyableBuilder::toBuilder; }
Example #9
Source File: ClientReflector.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
/** * Create the sync client to use in the tests. */ private Object createClient() { try { // Reflectively create a builder, configure it, and then create the client. Object untypedBuilder = interfaceClass.getMethod("builder").invoke(null); AwsClientBuilder<?, ?> builder = (AwsClientBuilder<?, ?>) untypedBuilder; return builder.credentialsProvider(getMockCredentials()) .region(Region.US_EAST_1) .endpointOverride(URI.create(getEndpoint())) .build(); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }
Example #10
Source File: ExecutionInterceptorTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private <T extends AwsClientBuilder<?, U>, U> U initializeAndBuild(T builder, ExecutionInterceptor interceptor) { return builder.region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid"))) .overrideConfiguration(ClientOverrideConfiguration.builder() .addExecutionInterceptor(interceptor) .build()) .build(); }
Example #11
Source File: KmsRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<AwsClientBuilder> createSyncBuilder(KmsConfig config, RuntimeValue<SdkHttpClient.Builder> transport) { KmsClientBuilder builder = KmsClient.builder(); if (transport != null) { builder.httpClientBuilder(transport.getValue()); } return new RuntimeValue<>(builder); }
Example #12
Source File: AmazonClientRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<AwsClientBuilder> configure(RuntimeValue<? extends AwsClientBuilder> clientBuilder, RuntimeValue<AwsConfig> awsConfig, RuntimeValue<SdkConfig> sdkConfig, SdkBuildTimeConfig sdkBuildTimeConfig, String awsServiceName) { AwsClientBuilder builder = clientBuilder.getValue(); initAwsClient(builder, awsServiceName, awsConfig.getValue()); initSdkClient(builder, awsServiceName, sdkConfig.getValue(), sdkBuildTimeConfig); return new RuntimeValue<>(builder); }
Example #13
Source File: KmsRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<AwsClientBuilder> createAsyncBuilder(KmsConfig config, RuntimeValue<SdkAsyncHttpClient.Builder> transport) { KmsAsyncClientBuilder builder = KmsAsyncClient.builder(); if (transport != null) { builder.httpClientBuilder(transport.getValue()); } return new RuntimeValue<>(builder); }
Example #14
Source File: AbstractAmazonServiceProcessor.java From quarkus with Apache License 2.0 | 5 votes |
protected void buildClients(List<AmazonClientBuilderConfiguredBuildItem> configuredClients, Function<RuntimeValue<? extends AwsClientBuilder>, RuntimeValue<? extends SdkClient>> syncClient, Function<RuntimeValue<? extends AwsClientBuilder>, RuntimeValue<? extends SdkClient>> asyncClient) { for (AmazonClientBuilderConfiguredBuildItem client : configuredClients) { if (configName().equals(client.getAwsClientName())) { if (client.getSyncBuilder() != null) { syncClient.apply(client.getSyncBuilder()); } if (client.getAsyncBuilder() != null) { asyncClient.apply(client.getAsyncBuilder()); } } } }
Example #15
Source File: KmsRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<KmsClient> buildClient(RuntimeValue<? extends AwsClientBuilder> builder, BeanContainer beanContainer, ShutdownContext shutdown) { KmsClientProducer producer = beanContainer.instance(KmsClientProducer.class); producer.setSyncConfiguredBuilder((KmsClientBuilder) builder.getValue()); shutdown.addShutdownTask(producer::destroy); return new RuntimeValue<>(producer.client()); }
Example #16
Source File: S3Recorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<S3AsyncClient> buildAsyncClient(RuntimeValue<? extends AwsClientBuilder> builder, BeanContainer beanContainer, ShutdownContext shutdown) { S3ClientProducer producer = beanContainer.instance(S3ClientProducer.class); producer.setAsyncConfiguredBuilder((S3AsyncClientBuilder) builder.getValue()); shutdown.addShutdownTask(producer::destroy); return new RuntimeValue<>(producer.asyncClient()); }
Example #17
Source File: S3Recorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<S3Client> buildClient(RuntimeValue<? extends AwsClientBuilder> builder, BeanContainer beanContainer, ShutdownContext shutdown) { S3ClientProducer producer = beanContainer.instance(S3ClientProducer.class); producer.setSyncConfiguredBuilder((S3ClientBuilder) builder.getValue()); shutdown.addShutdownTask(producer::destroy); return new RuntimeValue<>(producer.client()); }
Example #18
Source File: KmsRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<KmsAsyncClient> buildAsyncClient(RuntimeValue<? extends AwsClientBuilder> builder, BeanContainer beanContainer, ShutdownContext shutdown) { KmsClientProducer producer = beanContainer.instance(KmsClientProducer.class); producer.setAsyncConfiguredBuilder((KmsAsyncClientBuilder) builder.getValue()); shutdown.addShutdownTask(producer::destroy); return new RuntimeValue<>(producer.asyncClient()); }
Example #19
Source File: S3Recorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<AwsClientBuilder> createSyncBuilder(S3Config config, RuntimeValue<Builder> transport) { S3ClientBuilder builder = S3Client.builder(); configureS3Client(builder, config); if (transport != null) { builder.httpClientBuilder(transport.getValue()); } return new RuntimeValue<>(builder); }
Example #20
Source File: DynamodbRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<DynamoDbAsyncClient> buildAsyncClient(RuntimeValue<? extends AwsClientBuilder> builder, BeanContainer beanContainer, ShutdownContext shutdown) { DynamodbClientProducer producer = beanContainer.instance(DynamodbClientProducer.class); producer.setAsyncConfiguredBuilder((DynamoDbAsyncClientBuilder) builder.getValue()); shutdown.addShutdownTask(producer::destroy); return new RuntimeValue<>(producer.asyncClient()); }
Example #21
Source File: DynamodbRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<DynamoDbClient> buildClient(RuntimeValue<? extends AwsClientBuilder> builder, BeanContainer beanContainer, ShutdownContext shutdown) { DynamodbClientProducer producer = beanContainer.instance(DynamodbClientProducer.class); producer.setSyncConfiguredBuilder((DynamoDbClientBuilder) builder.getValue()); shutdown.addShutdownTask(producer::destroy); return new RuntimeValue<>(producer.client()); }
Example #22
Source File: SqsRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<SqsClient> buildClient(RuntimeValue<? extends AwsClientBuilder> builder, BeanContainer beanContainer, ShutdownContext shutdown) { SqsClientProducer producer = beanContainer.instance(SqsClientProducer.class); producer.setSyncConfiguredBuilder((SqsClientBuilder) builder.getValue()); shutdown.addShutdownTask(producer::destroy); return new RuntimeValue<>(producer.client()); }
Example #23
Source File: SesRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<AwsClientBuilder> createSyncBuilder(SesConfig config, RuntimeValue<SdkHttpClient.Builder> transport) { SesClientBuilder builder = SesClient.builder(); if (transport != null) { builder.httpClientBuilder(transport.getValue()); } return new RuntimeValue<>(builder); }
Example #24
Source File: SesRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<AwsClientBuilder> createAsyncBuilder(SesConfig config, RuntimeValue<SdkAsyncHttpClient.Builder> transport) { SesAsyncClientBuilder builder = SesAsyncClient.builder(); if (transport != null) { builder.httpClientBuilder(transport.getValue()); } return new RuntimeValue<>(builder); }
Example #25
Source File: SesRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<SesClient> buildClient(RuntimeValue<? extends AwsClientBuilder> builder, BeanContainer beanContainer, ShutdownContext shutdown) { SesClientProducer producer = beanContainer.instance(SesClientProducer.class); producer.setSyncConfiguredBuilder((SesClientBuilder) builder.getValue()); shutdown.addShutdownTask(producer::destroy); return new RuntimeValue<>(producer.client()); }
Example #26
Source File: SesRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<SesAsyncClient> buildAsyncClient(RuntimeValue<? extends AwsClientBuilder> builder, BeanContainer beanContainer, ShutdownContext shutdown) { SesClientProducer producer = beanContainer.instance(SesClientProducer.class); producer.setAsyncConfiguredBuilder((SesAsyncClientBuilder) builder.getValue()); shutdown.addShutdownTask(producer::destroy); return new RuntimeValue<>(producer.asyncClient()); }
Example #27
Source File: SqsRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<AwsClientBuilder> createSyncBuilder(SqsConfig config, RuntimeValue<Builder> transport) { SqsClientBuilder builder = SqsClient.builder(); if (transport != null) { builder.httpClientBuilder(transport.getValue()); } return new RuntimeValue<>(builder); }
Example #28
Source File: SqsRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<AwsClientBuilder> createAsyncBuilder(SqsConfig config, RuntimeValue<SdkAsyncHttpClient.Builder> transport) { SqsAsyncClientBuilder builder = SqsAsyncClient.builder(); if (transport != null) { builder.httpClientBuilder(transport.getValue()); } return new RuntimeValue<>(builder); }
Example #29
Source File: DynamodbRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<AwsClientBuilder> createAsyncBuilder(DynamodbConfig config, RuntimeValue<SdkAsyncHttpClient.Builder> transport) { DynamoDbAsyncClientBuilder builder = DynamoDbAsyncClient.builder(); builder.endpointDiscoveryEnabled(config.enableEndpointDiscovery); if (transport != null) { builder.httpClientBuilder(transport.getValue()); } return new RuntimeValue<>(builder); }
Example #30
Source File: SqsRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public RuntimeValue<SqsAsyncClient> buildAsyncClient(RuntimeValue<? extends AwsClientBuilder> builder, BeanContainer beanContainer, ShutdownContext shutdown) { SqsClientProducer producer = beanContainer.instance(SqsClientProducer.class); producer.setAsyncConfiguredBuilder((SqsAsyncClientBuilder) builder.getValue()); shutdown.addShutdownTask(producer::destroy); return new RuntimeValue<>(producer.asyncClient()); }