{"id":500,"library":"google-cloud-resource-manager","title":"Google Cloud Resource Manager","description":"The Google Cloud Resource Manager API client library provides Python methods to programmatically manage Google Cloud projects, folders, and organizations. This library (version 1.17.0) is actively maintained as part of the broader `google-cloud-python` ecosystem, with frequent releases to add features and address issues.","status":"active","version":"1.17.0","language":"python","source_language":"en","source_url":"https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-resource-manager","tags":["google-cloud","gcp","resource-manager","projects","folders","organizations","cloud-management"],"install":[{"cmd":"pip install google-cloud-resource-manager","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"For client libraries, always import the specific versioned module (e.g., `resourcemanager_v3`) instead of the top-level package, which might not expose client classes directly or could be an older, deprecated API version.","wrong":"from google.cloud import resource_manager","symbol":"ProjectsClient","correct":"from google.cloud.resourcemanager_v3 import ProjectsClient"},{"symbol":"FoldersClient","correct":"from google.cloud.resourcemanager_v3 import FoldersClient"},{"symbol":"OrganizationsClient","correct":"from google.cloud.resourcemanager_v3 import OrganizationsClient"}],"quickstart":{"code":"import os\nfrom google.cloud.resourcemanager_v3 import ProjectsClient\nfrom google.api_core.exceptions import GoogleAPIError\n\ndef list_projects():\n    # Ensure GOOGLE_APPLICATION_CREDENTIALS or gcloud auth is set up.\n    # For local development, 'gcloud auth application-default login' is recommended.\n    try:\n        client = ProjectsClient()\n        # The `search_projects` method can retrieve projects across the organization/folders\n        # depending on the authenticated identity's permissions.\n        # An empty query string lists all projects the user has permission to view.\n        print(\"Listing projects:\")\n        for project in client.search_projects(query=''):\n            print(f\"  Project Name: {project.display_name} (ID: {project.project_id})\")\n            print(f\"    State: {project.state.name}, Parent: {project.parent.type}/{project.parent.id}\")\n    except GoogleAPIError as e:\n        print(f\"An API error occurred: {e}\")\n        print(\"Ensure the Resource Manager API is enabled and you have necessary permissions.\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n\nif __name__ == '__main__':\n    # This assumes Application Default Credentials are set up.\n    # For example, by running `gcloud auth application-default login`\n    # or setting the GOOGLE_APPLICATION_CREDENTIALS environment variable.\n    if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS') and not os.environ.get('CLOUDSDK_CORE_ACCOUNT'):\n        print(\"WARNING: No explicit Google Cloud credentials found. This script relies on Application Default Credentials (ADC).\")\n        print(\"         Please run 'gcloud auth application-default login' or set GOOGLE_APPLICATION_CREDENTIALS.\")\n\n    list_projects()\n","lang":"python","description":"This quickstart initializes the `ProjectsClient` and then uses the `search_projects` method to list all Google Cloud projects accessible by the authenticated identity. It includes basic error handling and a reminder about setting up Application Default Credentials (ADC) for authentication."},"warnings":[{"fix":"Run `gcloud auth application-default login` to set up user credentials for local development. For production or CI/CD, ensure `GOOGLE_APPLICATION_CREDENTIALS` points to a Service Account key, and that the Service Account has appropriate `resourcemanager.*` roles at the organization or folder level (e.g., 'Project Creator', 'Organization Admin').","message":"Lack of configured Application Default Credentials (ADC) or insufficient permissions for resource management can cause failures. A common error is 'Your default credentials were not found' if ADC is not set up, or 'Permission Denied' if the authenticated principal lacks necessary roles (e.g., for creating projects/folders).","severity":"breaking","affected_versions":"All versions"},{"fix":"Always import from the specific versioned module, e.g., `from google.cloud.resourcemanager_v3 import ProjectsClient`.","message":"Older codebases or examples might use `from google.cloud import resource_manager`, which can lead to `ImportError: cannot import name 'resource_manager' from 'google.cloud'` or outdated API versions. Google Cloud client libraries typically use versioned imports.","severity":"gotcha","affected_versions":"Versions 1.x.x, especially when upgrading from very old `google-cloud` packages."},{"fix":"Prefer `client.search_projects(query='parent.type:organization parent.id:YOUR_ORG_ID')` or `client.search_projects(query='parent.type:folder parent.id:YOUR_FOLDER_ID')` for comprehensive project listing within a hierarchy.","message":"The `list_projects` method (if available in a specific client version/API) may only return direct child projects of a given parent. To recursively find all projects within an organization or folder hierarchy, use the `search_projects` method (which requires the `resourcemanager.projects.get` permission on all projects you wish to retrieve).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure Application Default Credentials are set up. Run `gcloud auth application-default login` in your terminal or set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the path of a service account key file.","message":"The application failed to find Google Cloud Application Default Credentials (ADC). This typically occurs when running a Google Cloud client library without prior authentication, either through `gcloud auth application-default login` or by explicitly setting the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.","severity":"breaking","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T14:24:19.052Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Enable the Cloud Resource Manager API via the Google Cloud Console (APIs & Services > Library) or ensure the service account/user has the `serviceusage.services.enable` permission (e.g., through `roles/editor` or `roles/serviceusage.serviceUsageAdmin`).","cause":"The Cloud Resource Manager API is not enabled for the specified Google Cloud project, or the authenticated identity lacks the necessary permissions to enable APIs in that project.","error":"PERMISSION_DENIED: Cloud Resource Manager API has not been used in the project [PROJECT_ID] before or it is disabled."},{"fix":"Ensure that `gcloud auth application-default login` has been executed locally, or verify that a service account is properly configured and its credentials are being used by setting the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the path of a valid service account key file.","cause":"The client application failed to provide valid authentication credentials, such as an OAuth 2 access token, or the provided credentials have expired.","error":"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project."},{"fix":"Install the library using `pip install google-cloud-resource-manager` and update your import statement to `from google.cloud import resourcemanager_v3` for recent versions.","cause":"The `google-cloud-resource-manager` library is either not installed in the current Python environment, or the import statement uses an outdated or incorrect path for the installed version.","error":"ModuleNotFoundError: No module named 'google.cloud.resourcemanager'"},{"fix":"Grant the necessary IAM role to the service account or user. For project-level operations, roles like `roles/resourcemanager.projectViewer`, `roles/resourcemanager.projectEditor`, or custom roles containing the specific permission are commonly required.","cause":"The authenticated user or service account lacks the specific IAM permission required to perform the requested operation (e.g., `resourcemanager.projects.get` to view project details) on the target Google Cloud resource.","error":"PERMISSION_DENIED: User [USER] does not have permission resourcemanager.projects.get (or similar resourcemanager.* permission)."}],"ecosystem":"pypi","meta_description":null,"install_score":95,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.27,"mem_mb":28.2,"disk_size":"71.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.09,"mem_mb":23.9,"disk_size":"69M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.63,"mem_mb":30.5,"disk_size":"76.1M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.61,"mem_mb":26.5,"disk_size":"74M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.62,"mem_mb":30.2,"disk_size":"67.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2,"mem_mb":26.5,"disk_size":"65M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.56,"mem_mb":30.6,"disk_size":"67.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.06,"mem_mb":26.6,"disk_size":"65M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.7,"mem_mb":28,"disk_size":"71.2M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.26,"mem_mb":23.8,"disk_size":"69M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}