Package io.micronaut.discovery.cloud
Class ComputeInstanceMetadataResolverUtils
java.lang.Object
io.micronaut.discovery.cloud.ComputeInstanceMetadataResolverUtils
Utility class for 
ComputeInstanceMetadataResolver's.- Since:
 - 1.1
 - Author:
 - Alvaro Sanchez-Mariscal
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic voidpopulateMetadata(AbstractComputeInstanceMetadata instanceMetadata, JsonNode metadata) Populates the instance metadata'sAbstractComputeInstanceMetadata.setMetadata(Map)property.static voidpopulateMetadata(AbstractComputeInstanceMetadata instanceMetadata, Map<?, ?> metadata) Populates the instance metadata'sAbstractComputeInstanceMetadata.setMetadata(Map)property.static com.fasterxml.jackson.databind.JsonNodereadMetadataUrl(URL url, int connectionTimeoutMs, int readTimeoutMs, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Map<String, String> requestProperties) Reads the result of a URL and parses it using the givenObjectMapper.static JsonNodereadMetadataUrl(URL url, int connectionTimeoutMs, int readTimeoutMs, JsonNodeTreeCodec treeCodec, com.fasterxml.jackson.core.JsonFactory jsonFactory, Map<String, String> requestProperties) Reads the result of a URL and parses it using the givenJsonFactory.static JsonNodereadMetadataUrl(URL url, int connectionTimeoutMs, int readTimeoutMs, JsonMapper jsonMapper, Map<String, String> requestProperties) Reads the result of a URL and parses it using the givenJsonMapper.stringValue(com.fasterxml.jackson.databind.JsonNode json, String key) Resolve a value as a string from the metadata json. 
- 
Constructor Details
- 
ComputeInstanceMetadataResolverUtils
public ComputeInstanceMetadataResolverUtils() 
 - 
 - 
Method Details
- 
readMetadataUrl
public static com.fasterxml.jackson.databind.JsonNode readMetadataUrl(URL url, int connectionTimeoutMs, int readTimeoutMs, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Map<String, String> requestProperties) throws IOExceptionReads the result of a URL and parses it using the givenObjectMapper.- Parameters:
 url- the URL to readconnectionTimeoutMs- connection timeout, in millisecondsreadTimeoutMs- read timeout, in millisecondsobjectMapper- Jackson'sObjectMapperrequestProperties- any request properties to pass- Returns:
 - a 
JsonNodeinstance - Throws:
 IOException- if any I/O error occurs
 - 
readMetadataUrl
public static JsonNode readMetadataUrl(URL url, int connectionTimeoutMs, int readTimeoutMs, JsonNodeTreeCodec treeCodec, com.fasterxml.jackson.core.JsonFactory jsonFactory, Map<String, String> requestProperties) throws IOExceptionReads the result of a URL and parses it using the givenJsonFactory.- Parameters:
 url- the URL to readconnectionTimeoutMs- connection timeout, in millisecondsreadTimeoutMs- read timeout, in millisecondstreeCodec- Tree codec to use (contains deserialization config)jsonFactory- Jackson'sJsonFactoryrequestProperties- any request properties to pass- Returns:
 - a 
JsonNodeinstance - Throws:
 IOException- if any I/O error occurs
 - 
readMetadataUrl
public static JsonNode readMetadataUrl(URL url, int connectionTimeoutMs, int readTimeoutMs, JsonMapper jsonMapper, Map<String, String> requestProperties) throws IOExceptionReads the result of a URL and parses it using the givenJsonMapper.- Parameters:
 url- the URL to readconnectionTimeoutMs- connection timeout, in millisecondsreadTimeoutMs- read timeout, in millisecondsjsonMapper- JSON mapper to use for parsingrequestProperties- any request properties to pass- Returns:
 - a 
JsonNodeinstance - Throws:
 IOException- if any I/O error occurs- Since:
 - 3.3.0
 
 - 
populateMetadata
public static void populateMetadata(AbstractComputeInstanceMetadata instanceMetadata, JsonNode metadata) Populates the instance metadata'sAbstractComputeInstanceMetadata.setMetadata(Map)property.- Parameters:
 instanceMetadata- The instance metadatametadata- A json object of metadata
 - 
stringValue
public static Optional<String> stringValue(com.fasterxml.jackson.databind.JsonNode json, String key) Resolve a value as a string from the metadata json.- Parameters:
 json- The jsonkey- The key- Returns:
 - An optional value
 
 - 
populateMetadata
public static void populateMetadata(AbstractComputeInstanceMetadata instanceMetadata, Map<?, ?> metadata) Populates the instance metadata'sAbstractComputeInstanceMetadata.setMetadata(Map)property.- Parameters:
 instanceMetadata- The instance metadatametadata- A map of metadata
 
 -