Skip to main content

contexts

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

Overview​

Namecontexts
TypeResource
Idgoogle.aiplatform.contexts

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringImmutable. The resource name of the Context.
createTimestring (google-datetime)Output only. Timestamp when this Context was created.
descriptionstringDescription of the Context
displayNamestringUser provided display name of the Context. May be up to 128 Unicode characters.
etagstringAn eTag used to perform consistent read-modify-write updates. If not set, a blind "overwrite" update happens.
labelsobjectThe labels with user-defined metadata to organize your Contexts. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. No more than 64 user labels can be associated with one Context (System labels are excluded).
metadataobjectProperties of the Context. Top level metadata keys' heading and trailing spaces will be trimmed. The size of this field should not exceed 200KB.
parentContextsarrayOutput only. A list of resource names of Contexts that are parents of this Context. A Context may have at most 10 parent_contexts.
schemaTitlestringThe title of the schema describing the metadata. Schema title and version is expected to be registered in earlier Create Schema calls. And both are used together as unique identifiers to identify schemas within the local metadata store.
schemaVersionstringThe version of the schema in schema_name to use. Schema title and version is expected to be registered in earlier Create Schema calls. And both are used together as unique identifiers to identify schemas within the local metadata store.
updateTimestring (google-datetime)Output only. Timestamp when this Context was last updated.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, metadataStoresId, contextsIdRetrieves a specific Context.
listselectprojectsId, locationsId, metadataStoresIdfilter, orderBy, pageSize, pageTokenLists Contexts on the MetadataStore.
createinsertprojectsId, locationsId, metadataStoresIdcontextIdCreates a Context associated with a MetadataStore.
patchupdateprojectsId, locationsId, metadataStoresId, contextsIdallowMissing, updateMaskUpdates a stored Context.
deletedeleteprojectsId, locationsId, metadataStoresId, contextsIdetag, forceDeletes a stored Context.
add_context_artifacts_and_executionsexecprojectsId, locationsId, metadataStoresId, contextsIdAdds a set of Artifacts and Executions to a Context. If any of the Artifacts or Executions have already been added to a Context, they are simply skipped.
add_context_childrenexecprojectsId, locationsId, metadataStoresId, contextsIdAdds a set of Contexts as children to a parent Context. If any of the child Contexts have already been added to the parent Context, they are simply skipped. If this call would create a cycle or cause any Context to have more than 10 parents, the request will fail with an INVALID_ARGUMENT error.
purgeexecprojectsId, locationsId, metadataStoresIdPurges Contexts.
remove_context_childrenexecprojectsId, locationsId, metadataStoresId, contextsIdRemove a set of children contexts from a parent Context. If any of the child Contexts were NOT added to the parent Context, they are simply skipped.
retrieve_contextsexecprojectsId, locationsIdRetrieves relevant contexts for a query.

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
contextsIdstring
locationsIdstring
metadataStoresIdstring
projectsIdstring
allowMissingboolean
contextIdstring
etagstring
filterstring
forceboolean
orderBystring
pageSizeinteger (int32)
pageTokenstring
updateMaskstring (google-fieldmask)

SELECT examples​

Retrieves a specific Context.

SELECT
name,
createTime,
description,
displayName,
etag,
labels,
metadata,
parentContexts,
schemaTitle,
schemaVersion,
updateTime
FROM google.aiplatform.contexts
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND metadataStoresId = '{{ metadataStoresId }}' -- required
AND contextsId = '{{ contextsId }}' -- required
;

INSERT examples​

Creates a Context associated with a MetadataStore.

INSERT INTO google.aiplatform.contexts (
data__description,
data__displayName,
data__etag,
data__labels,
data__metadata,
data__name,
data__schemaTitle,
data__schemaVersion,
projectsId,
locationsId,
metadataStoresId,
contextId
)
SELECT
'{{ description }}',
'{{ displayName }}',
'{{ etag }}',
'{{ labels }}',
'{{ metadata }}',
'{{ name }}',
'{{ schemaTitle }}',
'{{ schemaVersion }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ metadataStoresId }}',
'{{ contextId }}'
RETURNING
name,
createTime,
description,
displayName,
etag,
labels,
metadata,
parentContexts,
schemaTitle,
schemaVersion,
updateTime
;

UPDATE examples​

Updates a stored Context.

UPDATE google.aiplatform.contexts
SET
data__description = '{{ description }}',
data__displayName = '{{ displayName }}',
data__etag = '{{ etag }}',
data__labels = '{{ labels }}',
data__metadata = '{{ metadata }}',
data__name = '{{ name }}',
data__schemaTitle = '{{ schemaTitle }}',
data__schemaVersion = '{{ schemaVersion }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND metadataStoresId = '{{ metadataStoresId }}' --required
AND contextsId = '{{ contextsId }}' --required
AND allowMissing = {{ allowMissing}}
AND updateMask = '{{ updateMask}}'
RETURNING
name,
createTime,
description,
displayName,
etag,
labels,
metadata,
parentContexts,
schemaTitle,
schemaVersion,
updateTime;

DELETE examples​

Deletes a stored Context.

DELETE FROM google.aiplatform.contexts
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND metadataStoresId = '{{ metadataStoresId }}' --required
AND contextsId = '{{ contextsId }}' --required
AND etag = '{{ etag }}'
AND force = '{{ force }}'
;

Lifecycle Methods​

Adds a set of Artifacts and Executions to a Context. If any of the Artifacts or Executions have already been added to a Context, they are simply skipped.

EXEC google.aiplatform.contexts.add_context_artifacts_and_executions
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@metadataStoresId='{{ metadataStoresId }}' --required,
@contextsId='{{ contextsId }}' --required
@@json=
'{
"artifacts": "{{ artifacts }}",
"executions": "{{ executions }}"
}'
;