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
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
populateMetadata
(AbstractComputeInstanceMetadata instanceMetadata, JsonNode metadata) Populates the instance metadata'sAbstractComputeInstanceMetadata.setMetadata(Map)
property.static void
populateMetadata
(AbstractComputeInstanceMetadata instanceMetadata, Map<?, ?> metadata) Populates the instance metadata'sAbstractComputeInstanceMetadata.setMetadata(Map)
property.static com.fasterxml.jackson.databind.JsonNode
readMetadataUrl
(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 JsonNode
readMetadataUrl
(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 JsonNode
readMetadataUrl
(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'sObjectMapper
requestProperties
- any request properties to pass- Returns:
- a
JsonNode
instance - 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'sJsonFactory
requestProperties
- any request properties to pass- Returns:
- a
JsonNode
instance - 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
JsonNode
instance - 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
-