Class Ec2MetadataResponse

java.lang.Object
software.amazon.awssdk.imds.Ec2MetadataResponse

public final class Ec2MetadataResponse extends Object
This class is used for response handling and parsing the metadata fetched by the get call in the Ec2MetadataClient interface. It provides convenience methods to the users to parse the metadata as a String and List. Also provides ways to parse the metadata as Document type if it is in the json format.
  • Method Details

    • create

      public static Ec2MetadataResponse create(String body)
      Create a Ec2MetadataResponse with the given body as its content.
      Parameters:
      body - the content of the response
      Returns:
      a Ec2MetadataResponse with the given body as its content.
    • asString

      public String asString()
      Returns:
      String Representation of the Metadata Response Body.
    • asList

      public List<String> asList()
      Splits the Metadata response body on new line character and returns it as a list.
      Returns:
      The Metadata response split on each line.
    • asDocument

      public Document asDocument()
      Parses the response String into a Document type. This method can be used for parsing the metadata in a String Json Format.
      Returns:
      Document Representation, as json, of the Metadata Response Body.
      Throws:
      UncheckedIOException - (wrapping a JsonParseException if the Response body is not of JSON format.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object