Metadata Clients¶
- class linode_metadata.metadata_client.MetadataClient(client: Client | None = None, base_url='http://169.254.169.254/v1', user_agent=None, token=None, timeout=10.0, managed_token=True, managed_token_expiry_seconds=3600, debug=False, debug_file=None)¶
The main sync client of the Linode Metadata Service.
The constructor of the client of Linode Metadata Service.
- Parameters:
base_url (str) – The base URL for Metadata API requests. Generally, you shouldn’t change this.
user_agent (str) – What to append to the User Agent of all requests made by this client. Setting this allows Linode’s internal monitoring applications to track the usage of your application. Setting this is not necessary, but some applications may desire this behavior.
token (Optional[str]) – An existing token to use with this client. This field cannot be specified when token management is enabled.
timeout (float) – Timeout of an API call in seconds.
managed_token (bool) – If true, the token for this client will be automatically generated and refreshed.
managed_token_expiry_seconds (int) – The number of seconds until a managed token should expire. (Default 3600)
debug (bool) – Enables debug mode if set to True.
debug_file (str) – The file location to output the debug logs. Default to sys.stderr if not specified.
- check_connection()¶
Checks for a connection to the Metadata Service, ensuring customer is inside a Linode.
- close()¶
Close the embedded HTTP client in this metadata client.
- generate_token(expiry_seconds=3600) MetadataToken¶
Generates a token for accessing Metadata Service. NOTE: The generated token will NOT be implicitly applied to the MetadataClient.
- get_instance() InstanceResponse¶
Returns information about the running Linode instance.
- get_network() NetworkResponse¶
Returns information about the running Linode instance’s network configuration.
- get_ssh_keys() SSHKeysResponse¶
Get a mapping of public SSH Keys configured on your running Linode instance.
- get_user_data() str¶
Returns the user data configured on your running Linode instance.
- refresh_token(expiry_seconds: int = 3600) MetadataToken¶
Regenerates a Metadata Service token.
- class linode_metadata.metadata_client.AsyncMetadataClient(client: AsyncClient | None = None, base_url: str = 'http://169.254.169.254/v1', user_agent: str | None = None, token: str | None = None, timeout: float = 10.0, managed_token: bool = True, managed_token_expiry_seconds: float = 3600.0, debug: bool = False, debug_file: Path | str | None = None)¶
The main async client of the Linode Metadata Service.
The constructor of the async client of Linode Metadata Service.
- Parameters:
base_url (str) – The base URL for Metadata API requests. Generally, you shouldn’t change this.
user_agent (str) – What to append to the User Agent of all requests made by this client. Setting this allows Linode’s internal monitoring applications to track the usage of your application. Setting this is not necessary, but some applications may desire this behavior.
token (Optional[str]) – An existing token to use with this client. This field cannot be specified when token management is enabled.
timeout (float) – Timeout of an API call in seconds.
managed_token (bool) – If true, the token for this client will be automatically generated and refreshed.
managed_token_expiry_seconds (int) – The number of seconds until a managed token should expire. (Default 3600)
debug (bool) – Enables debug mode if set to True.
debug_file (str) – The file location to output the debug logs. Default to sys.stderr if not specified.
- async check_connection() None¶
Checks for a connection to the Metadata Service, ensuring customer is inside a Linode.
- async close()¶
Close the embedded HTTP client in this metadata client.
- async generate_token(expiry_seconds=3600) MetadataToken¶
Generates a token for accessing Metadata Service. NOTE: The generated token will NOT be implicitly applied to the MetadataClient.
- async get_instance() InstanceResponse¶
Returns information about the running Linode instance.
- async get_network() NetworkResponse¶
Returns information about the running Linode instance’s network configuration.
- async get_ssh_keys() SSHKeysResponse¶
Get a mapping of public SSH Keys configured on your running Linode instance.
- async get_user_data() str¶
Returns the user data configured on your running Linode instance.
- async refresh_token(expiry_seconds: int = 3600) MetadataToken¶
Regenerates a Metadata Service token.