keys
Creates, updates, deletes, gets or lists a keys
resource.
Overview
Name | keys |
Type | Resource |
Id | google.apikeys.keys |
Fields
Name | Datatype | Description |
---|---|---|
name | string | Output 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 . |
annotations | object | Annotations 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. |
createTime | string | Output only. A timestamp identifying the time this key was originally created. |
deleteTime | string | Output only. A timestamp when this key was deleted. If the resource is not deleted, this must be empty. |
displayName | string | Human-readable display name of this key that you can modify. The maximum length is 63 characters. |
etag | string | Output 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. |
keyString | string | Output only. An encrypted and signed value held by this key. This field can be accessed only through the GetKeyString method. |
restrictions | object | Describes the restrictions on the key. |
uid | string | Output only. Unique id in UUID4 format. |
updateTime | string | Output only. A timestamp identifying the time this key was last updated. |
Methods
Name | Accessible by | Required Params | Description |
---|---|---|---|
get | SELECT | keysId, locationsId, projectsId | Gets 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 . |
list | SELECT | locationsId, projectsId | 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 . |
create | INSERT | locationsId, projectsId | Creates a new API key. NOTE: Key is a global resource; hence the only supported value for location is global . |
delete | DELETE | keysId, locationsId, projectsId | Deletes 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 . |
patch | UPDATE | keysId, locationsId, projectsId | Patches 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_key | EXEC |
| Find 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. |
undelete | EXEC | keysId, locationsId, projectsId | Undeletes 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.
- All Properties
- Manifest
/*+ create */
INSERT INTO google.apikeys.keys (
locationsId,
projectsId,
restrictions,
displayName,
annotations
)
SELECT
'{{ locationsId }}',
'{{ projectsId }}',
'{{ restrictions }}',
'{{ displayName }}',
'{{ annotations }}'
;
- name: your_resource_model_name
props:
- name: restrictions
value:
- name: serverKeyRestrictions
value:
- name: allowedIps
value:
- string
- name: browserKeyRestrictions
value:
- name: allowedReferrers
value:
- string
- name: androidKeyRestrictions
value:
- name: allowedApplications
value:
- - name: sha1Fingerprint
value: string
- name: packageName
value: string
- name: iosKeyRestrictions
value:
- name: allowedBundleIds
value:
- string
- name: apiTargets
value:
- - name: methods
value:
- string
- name: service
value: string
- name: deleteTime
value: string
- name: createTime
value: string
- name: displayName
value: string
- name: updateTime
value: string
- name: annotations
value: object
- name: name
value: string
- name: uid
value: string
- name: keyString
value: string
- name: etag
value: string
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 }}';