Class DefaultEc2MetadataClient.Ec2MetadataBuilder
- java.lang.Object
-
- software.amazon.awssdk.imds.internal.DefaultEc2MetadataClient.Ec2MetadataBuilder
-
- All Implemented Interfaces:
Ec2MetadataClient.Builder,Ec2MetadataClientBuilder<Ec2MetadataClient.Builder,Ec2MetadataClient>,Buildable,SdkBuilder<Ec2MetadataClientBuilder<Ec2MetadataClient.Builder,Ec2MetadataClient>,Ec2MetadataClient>
- Enclosing class:
- DefaultEc2MetadataClient
protected static final class DefaultEc2MetadataClient.Ec2MetadataBuilder extends Object implements Ec2MetadataClient.Builder
-
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface software.amazon.awssdk.utils.builder.SdkBuilder
applyMutation
-
-
-
-
Method Detail
-
retryPolicy
public DefaultEc2MetadataClient.Ec2MetadataBuilder retryPolicy(Ec2MetadataRetryPolicy retryPolicy)
Description copied from interface:Ec2MetadataClientBuilderDefine the retry policy which includes the number of retry attempts for any failed request.If not specified, defaults to 3 retry attempts and a
BackoffStrategy.defaultStrategy()backoff strategy} that usesRetryMode.STANDARD. Can be also specified by using theEc2MetadataClientBuilder.retryPolicy(Consumer)method. if any of the retryPolicy methods are called multiple times, only the last invocation will be considered.- Specified by:
retryPolicyin interfaceEc2MetadataClientBuilder<Ec2MetadataClient.Builder,Ec2MetadataClient>- Parameters:
retryPolicy- The retry policy which includes the number of retry attempts for any failed request.- Returns:
- a reference to this builder
-
retryPolicy
public Ec2MetadataClient.Builder retryPolicy(Consumer<Ec2MetadataRetryPolicy.Builder> builderConsumer)
Description copied from interface:Ec2MetadataClientBuilderDefine the retry policy which includes the number of retry attempts for any failed request. Can be used instead ofEc2MetadataClientBuilder.retryPolicy(Ec2MetadataRetryPolicy)to use a "fluent consumer" syntax. User should not manually build the builder in the consumer.If not specified, defaults to 3 retry attempts and a
BackoffStrategy.defaultStrategy()backoff strategy} that usesRetryMode.STANDARD. Can be also specified by using theEc2MetadataClientBuilder.retryPolicy(Ec2MetadataRetryPolicy)method. if any of the retryPolicy methods are called multiple times, only the last invocation will be considered.- Specified by:
retryPolicyin interfaceEc2MetadataClientBuilder<Ec2MetadataClient.Builder,Ec2MetadataClient>- Parameters:
builderConsumer- the consumer- Returns:
- a reference to this builder
-
endpoint
public DefaultEc2MetadataClient.Ec2MetadataBuilder endpoint(URI endpoint)
Description copied from interface:Ec2MetadataClientBuilderDefine the endpoint of IMDS.If not specified, the IMDS client will attempt to automatically resolve the endpoint value based on the logic of
Ec2MetadataEndpointProvider.- Specified by:
endpointin interfaceEc2MetadataClientBuilder<Ec2MetadataClient.Builder,Ec2MetadataClient>- Parameters:
endpoint- The endpoint of IMDS.- Returns:
- a reference to this builder
-
tokenTtl
public DefaultEc2MetadataClient.Ec2MetadataBuilder tokenTtl(Duration tokenTtl)
Description copied from interface:Ec2MetadataClientBuilderDefine the Time to live (TTL) of the token. The token represents a logical session. The TTL specifies the length of time that the token is valid and, therefore, the duration of the session. Defaults to 21,600 seconds (6 hours) if not specified.- Specified by:
tokenTtlin interfaceEc2MetadataClientBuilder<Ec2MetadataClient.Builder,Ec2MetadataClient>- Parameters:
tokenTtl- The Time to live (TTL) of the token.- Returns:
- a reference to this builder
-
endpointMode
public DefaultEc2MetadataClient.Ec2MetadataBuilder endpointMode(EndpointMode endpointMode)
Description copied from interface:Ec2MetadataClientBuilderDefine the endpoint mode of IMDS. Supported values include IPv4 and IPv6. Used to determine the endpoint of the IMDS Client only ifEc2MetadataClientBuilder.endpoint(URI)is not specified. Only one of both endpoint or endpoint mode but not both. If both are specified in the Builder, aIllegalArgumentExceptionwill be thrown.If not specified, the IMDS client will attempt to automatically resolve the endpoint mode value based on the logic of
Ec2MetadataEndpointProvider.- Specified by:
endpointModein interfaceEc2MetadataClientBuilder<Ec2MetadataClient.Builder,Ec2MetadataClient>- Parameters:
endpointMode- The endpoint mode of IMDS. Supported values include IPv4 and IPv6.- Returns:
- a reference to this builder
-
httpClient
public DefaultEc2MetadataClient.Ec2MetadataBuilder httpClient(SdkHttpClient httpClient)
Description copied from interface:Ec2MetadataClient.BuilderDefine the http client used by the Ec2 Metadata client. If provided, the Ec2MetadataClient will NOT manage the lifetime if the httpClient and must therefore be closed explicitly by calling theSdkAutoCloseable.close()method on it.If not specified, the IMDS client will look for a SdkHttpClient class included in the classpath of the application and create a new instance of that class, managed by the IMDS Client, that will be closed when the IMDS Client is closed. If no such class can be found, will throw a
SdkClientException.- Specified by:
httpClientin interfaceEc2MetadataClient.Builder- Parameters:
httpClient- the http client- Returns:
- a reference to this builder
-
httpClient
public Ec2MetadataClient.Builder httpClient(SdkHttpClient.Builder<?> builder)
Description copied from interface:Ec2MetadataClient.BuilderA http client builder used to retrieve an instance of anSdkHttpClient. If specified, the Ec2 Metadata Client will use the instance returned by the builder and manage its lifetime by closing the http client once the Ec2 Client itself is closed.- Specified by:
httpClientin interfaceEc2MetadataClient.Builder- Parameters:
builder- the builder to used to retrieve an instance.- Returns:
- a reference to this builder
-
getRetryPolicy
public Ec2MetadataRetryPolicy getRetryPolicy()
-
getEndpoint
public URI getEndpoint()
-
getTokenTtl
public Duration getTokenTtl()
-
getEndpointMode
public EndpointMode getEndpointMode()
-
build
public Ec2MetadataClient build()
- Specified by:
buildin interfaceBuildable- Specified by:
buildin interfaceSdkBuilder<Ec2MetadataClientBuilder<Ec2MetadataClient.Builder,Ec2MetadataClient>,Ec2MetadataClient>
-
-