Skip to main content

A CLI utility to manage Google Cloud Platform resource hierarchy paths.

Project description

gcpath

gcpath is a CLI utility to manage Google Cloud Platform resource hierarchy paths. It helps you translate between GCP resource names (e.g., folders/12345) and human-readable paths (e.g., //example.com/department/team).

Features

  • Recursive Listing: List all folders in your organization as paths.
  • Path Resolution: Get the resource name (ID) for a given path.
  • Reverse Lookup: Get the path for a given resource name (ID).
  • Dual Mode:
    • Cloud Asset API (Default): Fast, bulk loading using GCP Cloud Asset Inventory.
    • Resource Manager API: Iterative loading using standard Resource Manager API (slower, but different permissions).

Quick Start

After installation, ensure you are authenticated with Google Cloud and have the necessary permissions.

# List all resources
gcpath ls

# Find ID of a specific path
gcpath name //example.com/engineering

# Find path of a specific resource ID
gcpath path folders/123456789

Authentication

gcpath uses Google Cloud Application Default Credentials (ADC).

Setup

  1. Install gcloud CLI.
  2. Authenticate:
    gcloud auth application-default login
    

For service accounts in CI/CD environments:

export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

Usage

List Folders

Recursively list all folders in your organization(s):

gcpath ls

Output:

//example.com/engineering
//example.com/engineering/backend
//example.com/sales
...

You can also filter by organization display name:

gcpath ls "example.com"

Get Resource Name

Get the GCP resource name (e.g., folders/123) from a path:

gcpath name //example.com/engineering/backend
# Output: folders/987654321

To get just the ID:

gcpath name --id //example.com/engineering/backend
# Output: 987654321

Get Path

Get the path from a resource name:

gcpath path folders/987654321
# Output: //example.com/engineering/backend

Tree View

Visualize the hierarchy in a tree format:

gcpath tree

Options:

  • -L, --level N: Limit depth of the tree.
  • -i, --ids: Include resource IDs in the output.

Modes

By default, gcpath uses the Cloud Asset API which is faster for large hierarchies. To force using the Resource Manager API (iterative), use the -U / --no-use-asset-api flag:

gcpath ls -U

Permissions

Cloud Asset API (Default)

Requires cloudasset.assets.searchAllResources permission on the Organization.

Resource Manager API

Requires resourcemanager.folders.list on the Organization and folders.

Development

Prerequisites: uv (https://github.com/astral-sh/uv).

  1. Clone the repository.
  2. Install dependencies:
    uv sync
    
  3. Run tests:
    uv run pytest
    

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcpath-0.1.3.tar.gz (48.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gcpath-0.1.3-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file gcpath-0.1.3.tar.gz.

File metadata

  • Download URL: gcpath-0.1.3.tar.gz
  • Upload date:
  • Size: 48.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gcpath-0.1.3.tar.gz
Algorithm Hash digest
SHA256 989821104236dcf2477bbaf351d32056fb8641a7fbc6ee2e96d44b33298e31f7
MD5 b55fd01c10a654d314c44b306f88272b
BLAKE2b-256 6e4c00eecc60dc7a9dd03a18a6df7cfa367f04fd4f3184f2659e1631b0794530

See more details on using hashes here.

Provenance

The following attestation bundles were made for gcpath-0.1.3.tar.gz:

Publisher: release.yml on tardigrde/gcpath

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gcpath-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: gcpath-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gcpath-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 badeaeea0e02c3357ec73f4d9857ba72f5a4cea752fd16557d705eb73a289a45
MD5 3973a7cd530b0a0240b19736482b1676
BLAKE2b-256 1b9585d646aa3a141d2cfcf25ef1eff1921f58ed3dbf84e6f2e8473b8bb5b88f

See more details on using hashes here.

Provenance

The following attestation bundles were made for gcpath-0.1.3-py3-none-any.whl:

Publisher: release.yml on tardigrde/gcpath

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page