Skip to main content

keys

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

Overview

Namekeys
TypeResource
Idgoogle.apikeys.keys

Fields

NameDatatypeDescription
namestringOutput only. The resource name of the key. The name has the form: projects//locations/global/keys/. For example: projects/123456867718/locations/global/keys/b7ff1f9f-8275-410a-94dd-3855ee9b5dd2 NOTE: Key is a global resource; hence the only supported value for location is global.
annotationsobjectAnnotations is an unstructured key-value map stored with a policy that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects.
createTimestringOutput only. A timestamp identifying the time this key was originally created.
deleteTimestringOutput only. A timestamp when this key was deleted. If the resource is not deleted, this must be empty.
displayNamestringHuman-readable display name of this key that you can modify. The maximum length is 63 characters.
etagstringOutput only. A checksum computed by the server based on the current value of the Key resource. This may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding. See https://google.aip.dev/154.
keyStringstringOutput only. An encrypted and signed value held by this key. This field can be accessed only through the GetKeyString method.
restrictionsobjectDescribes the restrictions on the key.
uidstringOutput only. Unique id in UUID4 format.
updateTimestringOutput only. A timestamp identifying the time this key was last updated.

Methods

NameAccessible byRequired ParamsDescription
getSELECTkeysId, locationsId, projectsIdGets the metadata for an API key. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is global.
listSELECTlocationsId, projectsIdLists the API keys owned by a project. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is global.
createINSERTlocationsId, projectsIdCreates a new API key. NOTE: Key is a global resource; hence the only supported value for location is global.
deleteDELETEkeysId, locationsId, projectsIdDeletes an API key. Deleted key can be retrieved within 30 days of deletion. Afterward, key will be purged from the project. NOTE: Key is a global resource; hence the only supported value for location is global.
patchUPDATEkeysId, locationsId, projectsIdPatches the modifiable fields of an API key. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is global.
lookup_keyEXECFind the parent project and resource name of the API key that matches the key string in the request. If the API key has been purged, resource name will not be set. The service account must have the apikeys.keys.lookup permission on the parent project.
undeleteEXECkeysId, locationsId, projectsIdUndeletes an API key which was deleted within 30 days. NOTE: Key is a global resource; hence the only supported value for location is global.

SELECT examples

Lists the API keys owned by a project. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is global.

SELECT
name,
annotations,
createTime,
deleteTime,
displayName,
etag,
keyString,
restrictions,
uid,
updateTime
FROM google.apikeys.keys
WHERE locationsId = '{{ locationsId }}'
AND projectsId = '{{ projectsId }}';

INSERT example

Use the following StackQL query and manifest file to create a new keys resource.

/*+ create */
INSERT INTO google.apikeys.keys (
locationsId,
projectsId,
restrictions,
displayName,
annotations
)
SELECT
'{{ locationsId }}',
'{{ projectsId }}',
'{{ restrictions }}',
'{{ displayName }}',
'{{ annotations }}'
;

UPDATE example

Updates a keys resource.

/*+ update */
UPDATE google.apikeys.keys
SET
restrictions = '{{ restrictions }}',
displayName = '{{ displayName }}',
annotations = '{{ annotations }}'
WHERE
keysId = '{{ keysId }}'
AND locationsId = '{{ locationsId }}'
AND projectsId = '{{ projectsId }}';

DELETE example

Deletes the specified keys resource.

/*+ delete */
DELETE FROM google.apikeys.keys
WHERE keysId = '{{ keysId }}'
AND locationsId = '{{ locationsId }}'
AND projectsId = '{{ projectsId }}';