1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */

15
16 package software.amazon.awssdk.core.client.config;
17
18 import java.net.URI;
19 import java.time.Duration;
20 import java.util.List;
21 import java.util.Map;
22 import java.util.concurrent.ScheduledExecutorService;
23 import software.amazon.awssdk.annotations.SdkProtectedApi;
24 import software.amazon.awssdk.core.ClientType;
25 import software.amazon.awssdk.core.ServiceConfiguration;
26 import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
27 import software.amazon.awssdk.core.retry.RetryPolicy;
28 import software.amazon.awssdk.http.SdkHttpClient;
29 import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
30 import software.amazon.awssdk.profiles.ProfileFile;
31
32 /**
33  * A set of internal options required by the SDK via {@link SdkClientConfiguration}.
34  */

35 @SdkProtectedApi
36 public final class SdkClientOption<T> extends ClientOption<T> {
37     /**
38      * @see ClientOverrideConfiguration#headers()
39      */

40     public static final SdkClientOption<Map<String, List<String>>> ADDITIONAL_HTTP_HEADERS =
41             new SdkClientOption<>(new UnsafeValueType(Map.class));
42
43     /**
44      * @see ClientOverrideConfiguration#retryPolicy()
45      */

46     public static final SdkClientOption<RetryPolicy> RETRY_POLICY = new SdkClientOption<>(RetryPolicy.class);
47
48     /**
49      * @see ClientOverrideConfiguration#executionInterceptors()
50      */

51     public static final SdkClientOption<List<ExecutionInterceptor>> EXECUTION_INTERCEPTORS =
52             new SdkClientOption<>(new UnsafeValueType(List.class));
53
54     /**
55      * The effective endpoint the client is configured to make requests to. If the client has been configured with
56      * an endpoint override then this value will be the provided endpoint value.
57      */

58     public static final SdkClientOption<URI> ENDPOINT = new SdkClientOption<>(URI.class);
59
60     /**
61      * A flag that when set to true indicates the endpoint stored in {@link SdkClientOption#ENDPOINT} was a customer
62      * supplied value and not generated by the client based on Region metadata.
63      */

64     public static final SdkClientOption<Boolean> ENDPOINT_OVERRIDDEN = new SdkClientOption<>(Boolean.class);
65
66     /**
67      * Service-specific configuration used by some services, like S3.
68      */

69     public static final SdkClientOption<ServiceConfiguration> SERVICE_CONFIGURATION =
70             new SdkClientOption<>(ServiceConfiguration.class);
71
72     /**
73      * Whether to calculate the CRC 32 checksum of a message based on the uncompressed data. By defaultthis is false.
74      */

75     public static final SdkClientOption<Boolean> CRC32_FROM_COMPRESSED_DATA_ENABLED =
76         new SdkClientOption<>(Boolean.class);
77
78     /**
79      * The internal SDK scheduled executor service that is used for scheduling tasks such as async retry attempts
80      * and timeout task.
81      */

82     public static final SdkClientOption<ScheduledExecutorService> SCHEDULED_EXECUTOR_SERVICE =
83             new SdkClientOption<>(ScheduledExecutorService.class);
84
85     /**
86      * The asynchronous HTTP client implementation to make HTTP requests with.
87      */

88     public static final SdkClientOption<SdkAsyncHttpClient> ASYNC_HTTP_CLIENT =
89             new SdkClientOption<>(SdkAsyncHttpClient.class);
90
91     /**
92      * The HTTP client implementation to make HTTP requests with.
93      */

94     public static final SdkClientOption<SdkHttpClient> SYNC_HTTP_CLIENT =
95             new SdkClientOption<>(SdkHttpClient.class);
96
97     /**
98      * The type of client used to make requests.
99      */

100     public static final SdkClientOption<ClientType> CLIENT_TYPE = new SdkClientOption<>(ClientType.class);
101
102     /**
103      * @see ClientOverrideConfiguration#apiCallAttemptTimeout()
104      */

105     public static final SdkClientOption<Duration> API_CALL_ATTEMPT_TIMEOUT = new SdkClientOption<>(Duration.class);
106
107     /**
108      * @see ClientOverrideConfiguration#apiCallTimeout()
109      */

110     public static final SdkClientOption<Duration> API_CALL_TIMEOUT = new SdkClientOption<>(Duration.class);
111
112     /**
113      * Descriptive name for the service. Used primarily for metrics and also in metadata like AwsErrorDetails.
114      */

115     public static final SdkClientOption<String> SERVICE_NAME = new SdkClientOption<>(String.class);
116
117     /**
118      * Whether or not endpoint discovery is enabled for this client.
119      */

120     public static final SdkClientOption<Boolean> ENDPOINT_DISCOVERY_ENABLED = new SdkClientOption<>(Boolean.class);
121
122     /**
123      * The profile file to use for this client.
124      */

125     public static final SdkClientOption<ProfileFile> PROFILE_FILE = new SdkClientOption<>(ProfileFile.class);
126
127     /**
128      * The profile name to use for this client.
129      */

130     public static final SdkClientOption<String> PROFILE_NAME = new SdkClientOption<>(String.class);
131
132     private SdkClientOption(Class<T> valueClass) {
133         super(valueClass);
134     }
135
136     private SdkClientOption(UnsafeValueType valueType) {
137         super(valueType);
138     }
139 }
140