{"id":2049,"library":"google-cloud-artifact-registry","title":"Google Cloud Artifact Registry","description":"The `google-cloud-artifact-registry` client library for Python allows developers to interact with Google Cloud Artifact Registry. This service provides a universal package manager for various artifact formats, including Docker images, Maven artifacts, npm packages, and more. The library is currently at version 1.21.0 and is part of the actively maintained Google Cloud Python client libraries, receiving frequent updates.","status":"active","version":"1.21.0","language":"en","source_language":"en","source_url":"https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-artifact-registry","tags":["Google Cloud","Artifact Registry","client library","package manager","GCP"],"install":[{"cmd":"pip install google-cloud-artifact-registry","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"ArtifactRegistryClient","correct":"from google.cloud.artifactregistry_v1 import ArtifactRegistryClient"},{"note":"Use the async client for non-blocking I/O operations.","symbol":"ArtifactRegistryAsyncClient","correct":"from google.cloud.artifactregistry_v1 import ArtifactRegistryAsyncClient"}],"quickstart":{"code":"import os\nfrom google.cloud.artifactregistry_v1 import ArtifactRegistryClient\n\ndef list_repositories(project_id: str, location: str):\n    \"\"\"Lists repositories in a given project and location.\"\"\"\n    client = ArtifactRegistryClient()\n    # The parent resource name for the project and location\n    parent = f\"projects/{project_id}/locations/{location}\"\n\n    try:\n        print(f\"Listing repositories in {parent}...\")\n        # list_repositories returns an iterator, common for Google Cloud APIs\n        repositories = client.list_repositories(parent=parent)\n        found = False\n        for repo in repositories:\n            print(f\"- {repo.name} (Format: {repo.format.name}, Description: {repo.description})\")\n            found = True\n        if not found:\n            print(\"No repositories found.\")\n    except Exception as e:\n        print(f\"Error listing repositories: {e}\")\n\nif __name__ == \"__main__\":\n    # Set these environment variables or replace the placeholders\n    PROJECT_ID = os.environ.get(\"GCP_PROJECT_ID\", \"your-gcp-project-id\")\n    LOCATION = os.environ.get(\"GCP_LOCATION\", \"us-central1\") # e.g., 'us-central1', 'europe-west1'\n\n    if PROJECT_ID == \"your-gcp-project-id\":\n        print(\"Please set the GCP_PROJECT_ID environment variable or replace 'your-gcp-project-id'.\")\n        print(\"Also ensure you are authenticated (e.g., `gcloud auth application-default login`).\")\n    else:\n        list_repositories(PROJECT_ID, LOCATION)\n","lang":"python","description":"This quickstart demonstrates how to initialize the `ArtifactRegistryClient` and list repositories within a specified Google Cloud project and location. It highlights the use of `parent` resource names and iterating over paginated results."},"warnings":[{"fix":"Always specify the correct `location` parameter in your API calls, typically in the `parent` resource name string (e.g., `projects/{project_id}/locations/{location}`).","message":"Artifact Registry resources (repositories, packages, artifacts) are regional. Operations like listing or creating repositories must specify a valid `location` (e.g., 'us-central1', 'europe-west1'). Forgetting this or using an incorrect region will result in 'NotFound' or 'PermissionDenied' errors, even if the resource exists in another region.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure that resource name strings are constructed precisely according to the API documentation. For instance, `client.repository_path(project, location, repository_id)` can be used to generate the correct format.","message":"Many Artifact Registry API calls require fully qualified resource names (e.g., `projects/PROJECT_ID/locations/LOCATION/repositories/REPOSITORY_ID`). Incorrectly formatting these strings is a common source of `INVALID_ARGUMENT` or `NotFound` errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Verify that the environment has access to valid credentials and that the principal (user or service account) has the necessary IAM roles (e.g., 'Artifact Registry Reader' or 'Artifact Registry Administrator') for the resources it's attempting to access.","message":"The client library uses Application Default Credentials for authentication. If your code is running outside of Google Cloud (e.g., on a local machine), you must explicitly authenticate (e.g., via `gcloud auth application-default login`) or set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. Incorrect setup often leads to `google.auth.exceptions.DefaultCredentialsError` or `PermissionDenied` errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}