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.0.tar.gz (46.6 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.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gcpath-0.1.0.tar.gz
  • Upload date:
  • Size: 46.6 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.0.tar.gz
Algorithm Hash digest
SHA256 fa27022c1dcd2b49a652260a3f69a8fb0512b3f40c20047bfa38625636b80d9d
MD5 a4913b5d939e31fae41e14c311b414fe
BLAKE2b-256 e943a144465494dab64be14e38977e8a4963823f5bc5b852422d567af6a6fd48

See more details on using hashes here.

Provenance

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

Publisher: ci.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.0-py3-none-any.whl.

File metadata

  • Download URL: gcpath-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8fc75834c4498052f1187af8aae4685f3fe422eea69fe9cc3dcfe5b0c6b04e0
MD5 bc93f71725356657c684cd0ce5453245
BLAKE2b-256 4e42eac95ec78aa29c1ba3919c3333d52ddf5d421fecff2f2afda63376177246

See more details on using hashes here.

Provenance

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

Publisher: ci.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