@Internal public class ComputeInstanceMetadataResolverUtils extends java.lang.Object
ComputeInstanceMetadataResolver
's.Constructor and Description |
---|
ComputeInstanceMetadataResolverUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
populateMetadata(AbstractComputeInstanceMetadata instanceMetadata,
java.util.Map<?,?> metadata)
Populates the instance instance metadata's
AbstractComputeInstanceMetadata.setMetadata(Map) property. |
static com.fasterxml.jackson.databind.JsonNode |
readMetadataUrl(java.net.URL url,
int connectionTimeoutMs,
int readTimeoutMs,
com.fasterxml.jackson.databind.ObjectMapper objectMapper,
java.util.Map<java.lang.String,java.lang.String> requestProperties)
Reads the result of a URL and parses it using the given
ObjectMapper . |
static java.util.Optional<java.lang.String> |
stringValue(com.fasterxml.jackson.databind.JsonNode json,
java.lang.String key)
Resolve a value as a string from the metadata json.
|
public ComputeInstanceMetadataResolverUtils()
public static com.fasterxml.jackson.databind.JsonNode readMetadataUrl(java.net.URL url, int connectionTimeoutMs, int readTimeoutMs, com.fasterxml.jackson.databind.ObjectMapper objectMapper, java.util.Map<java.lang.String,java.lang.String> requestProperties) throws java.io.IOException
ObjectMapper
.url
- the URL to readconnectionTimeoutMs
- connection timeout, in millisecondsreadTimeoutMs
- read timeout, in millisecondsobjectMapper
- Jackson's ObjectMapper
requestProperties
- any request properties to passJsonNode
instancejava.io.IOException
- if any I/O error occurspublic static java.util.Optional<java.lang.String> stringValue(com.fasterxml.jackson.databind.JsonNode json, java.lang.String key)
json
- The jsonkey
- The keypublic static void populateMetadata(AbstractComputeInstanceMetadata instanceMetadata, java.util.Map<?,?> metadata)
AbstractComputeInstanceMetadata.setMetadata(Map)
property.instanceMetadata
- The instance metadatametadata
- A map of metadata