Skip to main content

get_metadata

Get metadata string. Works on GAE(Google App Engine), GCF(Google Cloud Functions), and the others. For the detail, see https://cloud.google.com/appengine/docs/standard/java/accessing-instance-metadata

Installation;

pip install get_metadata

OR Write get_metadata in requirements.txt.

# requirements.txt sample
Flask  # sample
get_metadata
google-cloud-storage  # sample

How to use

from get_metadata import get_metadata

key = "project_id"
project_id = get_metadata(key)

key2 = "/computeMetadata/v1/instance/service-accounts/default/"
service_accounts = get_metadata(key2)

key accepts a key of key_list(see below) or metadata endpoint.

key_list: dict[str, str] = {
    # The project number assigned to your project.
    "numeric_project_id": "/computeMetadata/v1/project/numeric-project-id",
    # The project ID assigned to your project.
    "project_id": "/computeMetadata/v1/project/project-id",
    # The zone the instance is running in.
    "zone": "/computeMetadata/v1/instance/zone",
    # no description
    "aliases": "/computeMetadata/v1/instance/service-accounts/default/aliases",
    # The default service account email assigned to your project.
    "email": "/computeMetadata/v1/instance/service-accounts/default/email",
    # Lists all the default service accounts for your project.
    "service-accounts": "/computeMetadata/v1/instance/service-accounts/default/",
    # Lists all the supported scopes for the default service accounts.
    "scopes": "/computeMetadata/v1/instance/service-accounts/default/scopes",
    # Returns the auth token that can be used to authenticate your application to other Google Cloud APIs.
    "token": "/computeMetadata/v1/instance/service-accounts/default/token",
}

Release files for get-metadata 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for get-metadata 0.0.5
File Size Uploaded
get_metadata-0.0.5.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for get-metadata 0.0.5
File Interpreter ABI Platform
get_metadata-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 7.2 kB

Release files / get_metadata-0.0.5.tar.gz

Download URL get_metadata-0.0.5.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
578a5d313b9f36bd5d23956d933fef23b95b6e8347d10e1cdcd21fc9f92d2c57
BLAKE2b-256 checksum
How to use checksums
0bf105078d815aca5e1e493128763e400112a3bd960e5fb213b2b7065cf59693
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

Release files / get_metadata-0.0.5-py3-none-any.whl

Download URL get_metadata-0.0.5-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c02e905c97e769597224d778484a244219dea44bfce45af42154164a389a5db8
BLAKE2b-256 checksum
How to use checksums
15371f990ffd1c0b12c6d430df9f7c5efc6d5aeb8e57f0dddc49d4e470f062fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page