schemas
Creates, updates, deletes, gets or lists a schemas
resource.
Overview
Name | schemas |
Type | Resource |
Id | google.pubsub.schemas |
Fields
The following fields are returned by SELECT
queries:
- projects_schemas_get
- projects_schemas_list
Successful response
Name | Datatype | Description |
---|---|---|
name | string | Required. Name of the schema. Format is projects/{project}/schemas/{schema} . |
definition | string | The definition of the schema. This should contain a string representing the full definition of the schema that is a valid schema definition of the type specified in type . |
revisionCreateTime | string (google-datetime) | Output only. The timestamp that the revision was created. |
revisionId | string | Output only. Immutable. The revision ID of the schema. |
type | string | The type of the schema definition. |
Successful response
Name | Datatype | Description |
---|---|---|
name | string | Required. Name of the schema. Format is projects/{project}/schemas/{schema} . |
definition | string | The definition of the schema. This should contain a string representing the full definition of the schema that is a valid schema definition of the type specified in type . |
revisionCreateTime | string (google-datetime) | Output only. The timestamp that the revision was created. |
revisionId | string | Output only. Immutable. The revision ID of the schema. |
type | string | The type of the schema definition. |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
projects_schemas_get | select | projectsId , schemasId | view | Gets a schema. |
projects_schemas_list | select | projectsId | view , pageSize , pageToken | Lists schemas in a project. |
projects_schemas_create | insert | projectsId | schemaId | Creates a schema. |
projects_schemas_delete | delete | projectsId , schemasId | Deletes a schema. | |
projects_schemas_commit | exec | projectsId , schemasId | Commits a new schema revision to an existing schema. | |
projects_schemas_rollback | exec | projectsId , schemasId | Creates a new schema revision that is a copy of the provided revision_id. | |
projects_schemas_validate | exec | projectsId | Validates a schema. | |
projects_schemas_validate_message | exec | projectsId | Validates a message against a schema. |
Parameters
Parameters can be passed in the WHERE
clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
Name | Datatype | Description |
---|---|---|
projectsId | string | |
schemasId | string | |
pageSize | integer (int32) | |
pageToken | string | |
schemaId | string | |
view | string |
SELECT
examples
- projects_schemas_get
- projects_schemas_list
Gets a schema.
SELECT
name,
definition,
revisionCreateTime,
revisionId,
type
FROM google.pubsub.schemas
WHERE projectsId = '{{ projectsId }}' -- required
AND schemasId = '{{ schemasId }}' -- required
AND view = '{{ view }}';
Lists schemas in a project.
SELECT
name,
definition,
revisionCreateTime,
revisionId,
type
FROM google.pubsub.schemas
WHERE projectsId = '{{ projectsId }}' -- required
AND view = '{{ view }}'
AND pageSize = '{{ pageSize }}'
AND pageToken = '{{ pageToken }}';
INSERT
examples
- projects_schemas_create
- Manifest
Creates a schema.
INSERT INTO google.pubsub.schemas (
data__name,
data__type,
data__definition,
projectsId,
schemaId
)
SELECT
'{{ name }}',
'{{ type }}',
'{{ definition }}',
'{{ projectsId }}',
'{{ schemaId }}'
RETURNING
name,
definition,
revisionCreateTime,
revisionId,
type
;
# Description fields are for documentation purposes
- name: schemas
props:
- name: projectsId
value: string
description: Required parameter for the schemas resource.
- name: name
value: string
description: >
Required. Name of the schema. Format is `projects/{project}/schemas/{schema}`.
- name: type
value: string
description: >
The type of the schema definition.
valid_values: ['TYPE_UNSPECIFIED', 'PROTOCOL_BUFFER', 'AVRO']
- name: definition
value: string
description: >
The definition of the schema. This should contain a string representing the full definition of the schema that is a valid schema definition of the type specified in `type`.
- name: schemaId
value: string
DELETE
examples
- projects_schemas_delete
Deletes a schema.
DELETE FROM google.pubsub.schemas
WHERE projectsId = '{{ projectsId }}' --required
AND schemasId = '{{ schemasId }}' --required;
Lifecycle Methods
- projects_schemas_commit
- projects_schemas_rollback
- projects_schemas_validate
- projects_schemas_validate_message
Commits a new schema revision to an existing schema.
EXEC google.pubsub.schemas.projects_schemas_commit
@projectsId='{{ projectsId }}' --required,
@schemasId='{{ schemasId }}' --required
@@json=
'{
"schema": "{{ schema }}"
}';
Creates a new schema revision that is a copy of the provided revision_id.
EXEC google.pubsub.schemas.projects_schemas_rollback
@projectsId='{{ projectsId }}' --required,
@schemasId='{{ schemasId }}' --required
@@json=
'{
"revisionId": "{{ revisionId }}"
}';
Validates a schema.
EXEC google.pubsub.schemas.projects_schemas_validate
@projectsId='{{ projectsId }}' --required
@@json=
'{
"schema": "{{ schema }}"
}';
Validates a message against a schema.
EXEC google.pubsub.schemas.projects_schemas_validate_message
@projectsId='{{ projectsId }}' --required
@@json=
'{
"name": "{{ name }}",
"schema": "{{ schema }}",
"message": "{{ message }}",
"encoding": "{{ encoding }}"
}';