Skip to main content

schemas

Creates, updates, deletes, gets or lists a schemas resource.

Overview​

Nameschemas
TypeResource
Idgoogle.pubsub.schemas

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringRequired. Name of the schema. Format is projects/{project}/schemas/{schema}.
definitionstringThe 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.
revisionCreateTimestring (google-datetime)Output only. The timestamp that the revision was created.
revisionIdstringOutput only. Immutable. The revision ID of the schema.
typestringThe type of the schema definition. (TYPE_UNSPECIFIED, PROTOCOL_BUFFER, AVRO)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
projects_schemas_getselectprojectsId, schemasIdviewGets a schema.
projects_schemas_listselectprojectsIdpageSize, pageToken, viewLists schemas in a project.
projects_schemas_createinsertprojectsIdschemaIdCreates a schema.
projects_schemas_deletedeleteprojectsId, schemasIdDeletes a schema.
projects_schemas_commitexecprojectsId, schemasIdCommits a new schema revision to an existing schema.
projects_schemas_rollbackexecprojectsId, schemasIdCreates a new schema revision that is a copy of the provided revision_id.
projects_schemas_validateexecprojectsIdValidates a schema.
projects_schemas_validate_messageexecprojectsIdValidates 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.

NameDatatypeDescription
projectsIdstring
schemasIdstring
pageSizeinteger (int32)
pageTokenstring
schemaIdstring
viewstring

SELECT examples​

Gets a schema.

SELECT
name,
definition,
revisionCreateTime,
revisionId,
type
FROM google.pubsub.schemas
WHERE projectsId = '{{ projectsId }}' -- required
AND schemasId = '{{ schemasId }}' -- required
AND view = '{{ view }}'
;

INSERT examples​

Creates a schema.

INSERT INTO google.pubsub.schemas (
data__definition,
data__name,
data__type,
projectsId,
schemaId
)
SELECT
'{{ definition }}',
'{{ name }}',
'{{ type }}',
'{{ projectsId }}',
'{{ schemaId }}'
RETURNING
name,
definition,
revisionCreateTime,
revisionId,
type
;

DELETE examples​

Deletes a schema.

DELETE FROM google.pubsub.schemas
WHERE projectsId = '{{ projectsId }}' --required
AND schemasId = '{{ schemasId }}' --required
;

Lifecycle Methods​

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 }}"
}'
;