Class DefaultEc2MetadataClient

java.lang.Object
software.amazon.awssdk.imds.internal.BaseEc2MetadataClient
software.amazon.awssdk.imds.internal.DefaultEc2MetadataClient
All Implemented Interfaces:
AutoCloseable, Ec2MetadataClient, SdkAutoCloseable

@Immutable @ThreadSafe public final class DefaultEc2MetadataClient extends BaseEc2MetadataClient implements Ec2MetadataClient
An Implementation of the Ec2Metadata Interface.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • close

      public void close()
      Description copied from interface: SdkAutoCloseable
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface SdkAutoCloseable
    • builder

      public static software.amazon.awssdk.imds.internal.DefaultEc2MetadataClient.Ec2MetadataBuilder builder()
    • get

      public Ec2MetadataResponse get(String path)
      Gets the specified instance metadata value by the given path. Will retry base on the retry policy provided, in the case of an IOException during request. Will not retry on SdkClientException, like 4XX HTTP error.
      Specified by:
      get in interface Ec2MetadataClient
      Parameters:
      path - Input path of the resource to get.
      Returns:
      Instance metadata value as part of MetadataResponse Object
      Throws:
      SdkClientException - if the request for a token or the request for the Metadata does not have a 2XX SUCCESS response, if the maximum number of retries is reached, or if another IOException is thrown during the request.