You can list the schema registries in your project. This document shows you how to list schema registries using the Google Cloud console, the Google Cloud CLI, or the Managed Kafka API.
Required roles and permissions
To get the permissions that
you need to list schema registries,
ask your administrator to grant you the
Managed Kafka Schema Registry Viewer (roles/managedkafka.schemaRegistryViewer
)
IAM role on your project and location.
For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to list schema registries. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to list schema registries:
-
Grant the following permission on the parent location:
managedkafka.schemaRegistries.list
You might also be able to get these permissions with custom roles or other predefined roles.
Higher-level roles like Managed Kafka Schema Registry Editor
(roles/managedkafka.schemaRegistryEditor
) and
Managed Kafka Schema Registry Admin (roles/managedkafka.schemaRegistryAdmin
)
also lets you list schema registries.
For more information about predefined roles, see the Managed Service for Apache Kafka predefined roles.
List your schema registries
To list all your schema registries within your project, follow these steps.
Console
- In the Google Cloud console, go to the Schema registries page.
The page displays a list of schema registries in your project. The list includes columns for the following properties:
- Name: the unique identifier for the schema registry.
- Region: the Google Cloud region where the schema registry is hosted.
gcloud
-
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Run the
gcloud beta managed-kafka schema-registries list
command: - LOCATION (required): the Google Cloud region for which to list schema registries.
gcloud beta managed-kafka schema-registries list \ --location=LOCATION \
Replace the following:
For example, to list all schema registries in the us-central1
location, run the following command:
gcloud beta managed-kafka schema-registries list --location=us-central1
Sample output:
NAME LOCATION sr_docs us-central1 sr_docs23 us-central1 sr23wert us-central1
REST
To list schema registries using the REST API, perform the following steps.
- Make a
GET
request to the schema registries collection URI for the required project and location. - PROJECT_ID (required): your Google Cloud project ID.
- LOCATION (required): the Google Cloud region where you want to list the schema registries.
GET https://managedkafka.googleapis.com/v1main/projects/PROJECT_ID/locations/LOCATION/schemaRegistries Authorization: Bearer $(gcloud auth application-default print-access-token)
Replace the following:
If the request is successful, the API returns a 200 OK
status code.
The response body contains a JSON object. This object includes a list of
schema registry resources found in the specified location.
The following is a sample successful response:
{ "schemaRegistries": [ { "name": "projects/schema-test-project/location/us-central1/schemaRegistries/sr_docs", "contexts": [] }, { "name": "projects/schema-test-project/location/us-central1/schemaRegistries/moi_sr_docs23", "contexts": [] }, { "name": "projects/schema-test-project/location/us-central1/schemaRegistries/sr23wert", "contexts": [] } ] }
The list schema registry
call returns an empty context
field even in cases where the schema registry contains a context. To get the
list of contexts for a schema registry, you can run the
get schema registry
API call.
For more information about the REST API calls, see the
REST API documentation.