software.amazon.awssdk.services.eventbridge.DefaultEventBridgeBaseClientBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eventbridge Show documentation
Show all versions of eventbridge Show documentation
The AWS Java SDK for EventBridge module holds the client classes that are used for
communicating with EventBridge.
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.eventbridge;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme;
import software.amazon.awssdk.http.auth.aws.scheme.AwsV4aAuthScheme;
import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme;
import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.services.eventbridge.auth.scheme.EventBridgeAuthSchemeProvider;
import software.amazon.awssdk.services.eventbridge.auth.scheme.internal.EventBridgeAuthSchemeInterceptor;
import software.amazon.awssdk.services.eventbridge.endpoints.EventBridgeEndpointProvider;
import software.amazon.awssdk.services.eventbridge.endpoints.internal.EventBridgeRequestSetEndpointInterceptor;
import software.amazon.awssdk.services.eventbridge.endpoints.internal.EventBridgeResolveEndpointInterceptor;
import software.amazon.awssdk.services.eventbridge.internal.EventBridgeServiceClientConfigurationBuilder;
import software.amazon.awssdk.utils.CollectionUtils;
/**
* Internal base class for {@link DefaultEventBridgeClientBuilder} and {@link DefaultEventBridgeAsyncClientBuilder}.
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
abstract class DefaultEventBridgeBaseClientBuilder, C> extends
AwsDefaultClientBuilder {
private final Map> additionalAuthSchemes = new HashMap<>();
@Override
protected final String serviceEndpointPrefix() {
return "events";
}
@Override
protected final String serviceName() {
return "EventBridge";
}
@Override
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) {
return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider())
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider())
.option(SdkClientOption.AUTH_SCHEMES, authSchemes())
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false));
}
@Override
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) {
List endpointInterceptors = new ArrayList<>();
endpointInterceptors.add(new EventBridgeAuthSchemeInterceptor());
endpointInterceptors.add(new EventBridgeResolveEndpointInterceptor());
endpointInterceptors.add(new EventBridgeRequestSetEndpointInterceptor());
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List interceptors = interceptorFactory
.getInterceptors("software/amazon/awssdk/services/eventbridge/execution.interceptors");
List additionalInterceptors = new ArrayList<>();
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors);
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors);
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
SdkClientConfiguration.Builder builder = config.toBuilder();
builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> {
IdentityProviders.Builder result = IdentityProviders.builder();
IdentityProvider> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
if (credentialsIdentityProvider != null) {
result.putIdentityProvider(credentialsIdentityProvider);
}
return result.build();
});
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors);
return builder.build();
}
@Override
protected final String signingName() {
return "events";
}
private EventBridgeEndpointProvider defaultEndpointProvider() {
return EventBridgeEndpointProvider.defaultProvider();
}
public B authSchemeProvider(EventBridgeAuthSchemeProvider authSchemeProvider) {
clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider);
return thisBuilder();
}
private EventBridgeAuthSchemeProvider defaultAuthSchemeProvider() {
return EventBridgeAuthSchemeProvider.defaultProvider();
}
@Override
public B putAuthScheme(AuthScheme> authScheme) {
additionalAuthSchemes.put(authScheme.schemeId(), authScheme);
return thisBuilder();
}
private Map> authSchemes() {
Map> schemes = new HashMap<>(3 + this.additionalAuthSchemes.size());
AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create();
schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme);
AwsV4aAuthScheme awsV4aAuthScheme = AwsV4aAuthScheme.create();
schemes.put(awsV4aAuthScheme.schemeId(), awsV4aAuthScheme);
NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create();
schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme);
schemes.putAll(this.additionalAuthSchemes);
return schemes;
}
@Override
protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) {
List internalPlugins = internalPlugins(config);
List externalPlugins = plugins();
if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) {
return config;
}
List plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins);
SdkClientConfiguration.Builder configuration = config.toBuilder();
EventBridgeServiceClientConfigurationBuilder serviceConfigBuilder = new EventBridgeServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private List internalPlugins(SdkClientConfiguration config) {
return Collections.emptyList();
}
protected static void validateClientOptions(SdkClientConfiguration c) {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy