You can delete schemas with the Google Cloud console, Google Cloud CLI, client library, or Pub/Sub API.
Before you begin
- Understand how Pub/Sub schemas work.
- Create a schema.
Required roles and permissions
To get the permissions that you need to delete and manage schemas,
ask your administrator to grant you the
Pub/Sub Editor (roles/pubsub.editor
) IAM role on your project.
For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to delete and manage schemas. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to delete and manage schemas:
-
Create schema:
pubsub.schemas.create
-
Attach schema to topic:
pubsub.schemas.attach
-
Commit a schema revision:
pubsub.schemas.commit
-
Delete a schema or a schema revision:
pubsub.schemas.delete
-
Get a schema or schema revisions:
pubsub.schemas.get
-
List schemas:
pubsub.schemas.list
-
List schema revisions:
pubsub.schemas.listRevisions
-
Rollback a schema:
pubsub.schemas.rollback
-
Validate a message:
pubsub.schemas.validate
-
Get the IAM policy for a schema:
pubsub.schemas.getIamPolicy
-
Configure the IAM policy for a schema:
pubsub.schemas.setIamPolicy
You might also be able to get these permissions with custom roles or other predefined roles.
You can grant roles and permissions to principals such as users, groups, domains, or service accounts. You can create a schema in one project and attach it to a topic located in a different project. Ensure that you have the required permissions for each project.
Delete a schema
The delete operation for a schema also deletes all the revisions associated with the schema.
If you try to create a schema with the same name as the one that you just deleted, expect an error for a brief period.
Before deleting a schema, ensure you remove its association from a topic.
Console
In the Google Cloud console, go to the Pub/Sub schemas page.
Select one or more schemas that you want to delete.
Click Delete.
Confirm the delete operation.
gcloud
gcloud pubsub schemas delete SCHEMA_NAME
REST
To delete a schema send a DELETE request like the following:
DELETE https://pubsub.googleapis.com/v1/SCHEMA_NAME
C++
Before trying this sample, follow the C++ setup instructions in Quickstart: Using Client Libraries. For more information, see the Pub/Sub C++ API reference documentation.
C#
Before trying this sample, follow the C# setup instructions in Quickstart: Using Client Libraries. For more information, see the Pub/Sub C# API reference documentation.
Go
Before trying this sample, follow the Go setup instructions in Quickstart: Using Client Libraries. For more information, see the Pub/Sub Go API reference documentation.
Java
Before trying this sample, follow the Java setup instructions in Quickstart: Using Client Libraries. For more information, see the Pub/Sub Java API reference documentation.
Node.js
Before trying this sample, follow the Node.js setup instructions in Quickstart: Using Client Libraries. For more information, see the Pub/Sub Node.js API reference documentation.
Node.js
Before trying this sample, follow the Node.js setup instructions in Quickstart: Using Client Libraries. For more information, see the Pub/Sub Node.js API reference documentation.
PHP
Before trying this sample, follow the PHP setup instructions in Quickstart: Using Client Libraries. For more information, see the Pub/Sub PHP API reference documentation.
Python
Before trying this sample, follow the Python setup instructions in Quickstart: Using Client Libraries. For more information, see the Pub/Sub Python API reference documentation.
Ruby
Before trying this sample, follow the Ruby setup instructions in Quickstart: Using Client Libraries. For more information, see the Pub/Sub Ruby API reference documentation.