All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.wisdom.internal.WisdomServiceClientConfigurationBuilder Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Wisdom module holds the client classes that are used for communicating with Wisdom.

There is a newer version: 2.29.15
Show newest version
/*
 * 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.wisdom.internal;

import java.net.URI;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.endpoints.EndpointProvider;
import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme;
import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeProvider;
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.wisdom.WisdomServiceClientConfiguration;
import software.amazon.awssdk.services.wisdom.auth.scheme.WisdomAuthSchemeProvider;
import software.amazon.awssdk.utils.Validate;

@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class WisdomServiceClientConfigurationBuilder {
    public static WisdomServiceClientConfiguration.Builder builder() {
        return new BuilderImpl();
    }

    public static BuilderInternal builder(SdkClientConfiguration.Builder builder) {
        return new BuilderImpl(builder);
    }

    public interface BuilderInternal extends WisdomServiceClientConfiguration.Builder {
        SdkClientConfiguration buildSdkClientConfiguration();
    }

    public static class BuilderImpl implements BuilderInternal {
        private final SdkClientConfiguration.Builder internalBuilder;

        private ClientOverrideConfiguration overrideConfiguration;

        private URI endpointOverride;

        private IdentityProvider credentialsProvider;

        private Map> authSchemes;

        private BuilderImpl() {
            this.internalBuilder = SdkClientConfiguration.builder();
        }

        private BuilderImpl(SdkClientConfiguration.Builder internalBuilder) {
            this.internalBuilder = internalBuilder;
            if (Boolean.TRUE.equals(internalBuilder.option(SdkClientOption.ENDPOINT_OVERRIDDEN))) {
                this.endpointOverride = internalBuilder.option(SdkClientOption.ENDPOINT);
            }
            this.credentialsProvider = internalBuilder.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER);
            Map> authSchemes = internalBuilder.option(SdkClientOption.AUTH_SCHEMES);
            if (authSchemes != null) {
                authSchemes = new HashMap<>(authSchemes);
            }
            this.authSchemes = authSchemes;
        }

        /**
         * Sets the value for client override configuration
         */
        @Override
        public WisdomServiceClientConfiguration.Builder overrideConfiguration(ClientOverrideConfiguration overrideConfiguration) {
            this.overrideConfiguration = overrideConfiguration;
            return this;
        }

        /**
         * Gets the value for client override configuration
         */
        @Override
        public ClientOverrideConfiguration overrideConfiguration() {
            return overrideConfiguration;
        }

        /**
         * Sets the value for endpoint override
         */
        @Override
        public WisdomServiceClientConfiguration.Builder endpointOverride(URI endpointOverride) {
            this.endpointOverride = endpointOverride;
            return this;
        }

        /**
         * Gets the value for endpoint override
         */
        @Override
        public URI endpointOverride() {
            return endpointOverride;
        }

        /**
         * Sets the value for endpoint provider
         */
        @Override
        public WisdomServiceClientConfiguration.Builder endpointProvider(EndpointProvider endpointProvider) {
            internalBuilder.option(SdkClientOption.ENDPOINT_PROVIDER, endpointProvider);
            return this;
        }

        /**
         * Gets the value for endpoint provider
         */
        @Override
        public EndpointProvider endpointProvider() {
            return internalBuilder.option(SdkClientOption.ENDPOINT_PROVIDER);
        }

        /**
         * Sets the value for AWS region
         */
        @Override
        public WisdomServiceClientConfiguration.Builder region(Region region) {
            internalBuilder.option(AwsClientOption.AWS_REGION, region);
            return this;
        }

        /**
         * Gets the value for AWS region
         */
        @Override
        public Region region() {
            return internalBuilder.option(AwsClientOption.AWS_REGION);
        }

        /**
         * Sets the value for credentials provider
         */
        @Override
        public WisdomServiceClientConfiguration.Builder credentialsProvider(
                IdentityProvider credentialsProvider) {
            this.credentialsProvider = credentialsProvider;
            return this;
        }

        /**
         * Gets the value for credentials provider
         */
        @Override
        public IdentityProvider credentialsProvider() {
            return credentialsProvider;
        }

        @Override
        public WisdomServiceClientConfiguration.Builder putAuthScheme(AuthScheme authScheme) {
            if (authSchemes == null) {
                authSchemes = new HashMap<>();
            }
            authSchemes.put(authScheme.schemeId(), authScheme);
            return this;
        }

        @Override
        public Map> authSchemes() {
            if (authSchemes == null) {
                return Collections.emptyMap();
            }
            return Collections.unmodifiableMap(new HashMap<>(authSchemes));
        }

        /**
         * Sets the value for auth scheme provider
         */
        @Override
        public WisdomServiceClientConfiguration.Builder authSchemeProvider(WisdomAuthSchemeProvider authSchemeProvider) {
            internalBuilder.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider);
            return this;
        }

        /**
         * Gets the value for auth scheme provider
         */
        @Override
        public WisdomAuthSchemeProvider authSchemeProvider() {
            AuthSchemeProvider result = internalBuilder.option(SdkClientOption.AUTH_SCHEME_PROVIDER);
            if (result == null) {
                return null;
            }
            return Validate.isInstanceOf(WisdomAuthSchemeProvider.class, result, "Expected an instance of "
                    + WisdomAuthSchemeProvider.class.getSimpleName());
        }

        @Override
        public WisdomServiceClientConfiguration build() {
            return new WisdomServiceClientConfiguration(this);
        }

        @Override
        public SdkClientConfiguration buildSdkClientConfiguration() {
            if (overrideConfiguration != null) {
                SdkClientConfigurationUtil.copyOverridesToConfiguration(overrideConfiguration, internalBuilder);
            }
            if (endpointOverride != null) {
                internalBuilder.option(SdkClientOption.ENDPOINT, endpointOverride);
                internalBuilder.option(SdkClientOption.ENDPOINT_OVERRIDDEN, true);
            }
            if (credentialsProvider != null
                    && !credentialsProvider.equals(internalBuilder.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER))) {
                internalBuilder.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER, credentialsProvider);
                IdentityProviders identityProviders = internalBuilder.option(SdkClientOption.IDENTITY_PROVIDERS);
                if (identityProviders == null) {
                    identityProviders = IdentityProviders.builder().putIdentityProvider(credentialsProvider).build();
                } else {
                    identityProviders = identityProviders.toBuilder().putIdentityProvider(credentialsProvider).build();
                }
                internalBuilder.option(SdkClientOption.IDENTITY_PROVIDERS, identityProviders);
            }
            if (authSchemes != null && !authSchemes.equals(internalBuilder.option(SdkClientOption.AUTH_SCHEMES))) {
                internalBuilder.option(SdkClientOption.AUTH_SCHEMES, authSchemes());
            }
            return internalBuilder.build();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy