{"id":4553,"library":"google-cloud-access-context-manager","title":"Google Cloud Access Context Manager","description":"Google Cloud Access Context Manager is a Python client library for interacting with the Access Context Manager API. It enables Google Cloud organization administrators to programmatically define fine-grained, attribute-based access control policies, including access levels and service perimeters, for resources within Google Cloud. The library is currently at version 0.4.0 and receives regular updates to align with API evolution and bug fixes.","status":"active","version":"0.4.0","language":"en","source_language":"en","source_url":"https://github.com/googleapis/python-access-context-manager","tags":["google-cloud","access-control","security","iam","policy","cloud"],"install":[{"cmd":"pip install google-cloud-access-context-manager","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core dependency for Google Cloud client libraries; specific versions often required for compatibility.","package":"protobuf","optional":false},{"reason":"Provides core functionalities for Google Cloud client libraries, including API abstractions.","package":"google-api-core","optional":false},{"reason":"Handles authentication with Google Cloud services.","package":"google-auth","optional":false}],"imports":[{"note":"Client classes for Google Cloud often reside in versioned submodules like `accesscontextmanager_v1`.","wrong":"from google.cloud.accesscontextmanager import AccessContextManagerClient","symbol":"AccessContextManagerClient","correct":"from google.cloud import accesscontextmanager_v1"}],"quickstart":{"code":"import os\nfrom google.cloud import accesscontextmanager_v1\n\ndef list_access_policies(organization_id: str):\n    \"\"\"Lists all Access Policies for a given Google Cloud organization.\n\n    Args:\n        organization_id: The Google Cloud organization ID.\n    \"\"\"\n    # Create a client\n    client = accesscontextmanager_v1.AccessContextManagerClient()\n\n    # The parent format for listing access policies is 'organizations/{organization_id}'\n    parent = f\"organizations/{organization_id}\"\n\n    try:\n        print(f\"Listing Access Policies for organization: {organization_id}\")\n        # The list_access_policies method returns an iterable of policies.\n        for policy in client.list_access_policies(parent=parent):\n            print(f\"  Policy Name: {policy.name}, Title: {policy.title}\")\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n\nif __name__ == \"__main__\":\n    # Set your Google Cloud Organization ID as an environment variable\n    # Example: export GOOGLE_CLOUD_ORGANIZATION_ID='1234567890'\n    organization_id = os.environ.get(\"GOOGLE_CLOUD_ORGANIZATION_ID\")\n\n    if not organization_id:\n        print(\"ERROR: Please set the 'GOOGLE_CLOUD_ORGANIZATION_ID' environment variable.\")\n        print(\"You can usually find this in the Google Cloud Console or via `gcloud organizations list`.\")\n    else:\n        list_access_policies(organization_id)\n","lang":"python","description":"This quickstart demonstrates how to initialize the `google-cloud-access-context-manager` client and list all Access Policies associated with a specified Google Cloud organization. Ensure the `GOOGLE_CLOUD_ORGANIZATION_ID` environment variable is set and your authentication is configured (e.g., `gcloud auth application-default login`)."},"warnings":[{"fix":"Carefully manage your `protobuf` version by checking the `google-cloud-access-context-manager` library's `install_requires` in its `setup.py` or `pyproject.toml` (if available on PyPI) and ensuring compatibility with other installed packages. Use virtual environments to isolate dependencies.","message":"Frequent and specific `protobuf` version requirements can lead to dependency conflicts, especially when combining with other Google Cloud libraries or third-party tools that pin `protobuf` versions. This library has required `protobuf < 5.0.0` and later `protobuf >=3.20.2, <6`.","severity":"breaking","affected_versions":"All versions, particularly when upgrading or integrating with other Python packages."},{"fix":"Ensure your development and deployment environments are using Python 3.9 or newer. Upgrade your Python interpreter if necessary.","message":"This library (and underlying API) is designed for Python 3.9 and higher. Earlier Python versions (e.g., 3.8 and below) are not supported by recent releases, which can cause installation or runtime failures.","severity":"gotcha","affected_versions":"Versions >=0.1.13 officially require Python >=3.7, but current versions from PyPI (e.g., 0.4.0) now specify `>=3.9`."},{"fix":"Be aware of the 'preview' status when building critical systems. Monitor Google Cloud release notes for Access Context Manager for potential changes to APIs you rely on. Implement robust error handling and resilience in your applications.","message":"The Access Context Manager API is listed as 'preview' in some Google Cloud documentation contexts, implying that certain features or API surfaces might still be under active development and subject to change without standard deprecation periods.","severity":"gotcha","affected_versions":"All versions, as this relates to the underlying API stability."},{"fix":"For administrative tasks on Access Policies, always plan to use either the `gcloud` CLI or programmatically interact via the `google-cloud-access-context-manager` library. Refer to the official Google Cloud documentation for Access Context Manager for management instructions.","message":"Managing Access Policies (creating, updating, deleting) cannot be done directly through the Google Cloud Console. These operations must be performed using the `gcloud` command-line tool or through the Access Context Manager API via this client library.","severity":"gotcha","affected_versions":"All versions."},{"fix":"Refer to the monorepo at `https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-access-context-manager` for the latest source code, issues, and contributions.","message":"The original GitHub repository `googleapis/python-access-context-manager` has been archived. Development now occurs within the larger `googleapis/google-cloud-python` monorepo.","severity":"deprecated","affected_versions":"All versions; affects where to find source code and contribute."}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}