functions
Creates, updates, deletes, gets or lists a functions
resource.
Overview
Name | functions |
Type | Resource |
Id | google.cloudfunctions.functions |
Fields
The following fields are returned by SELECT
queries:
- get
- list
Successful response
Name | Datatype | Description |
---|---|---|
name | string | A user-defined name of the function. Function names must be unique globally and match pattern projects/*/locations/*/functions/* |
buildConfig | object | Describes the Build step of the function that builds a container from the given source. (id: BuildConfig) |
createTime | string (google-datetime) | Output only. The create timestamp of a Cloud Function. This is only applicable to 2nd Gen functions. |
description | string | User-provided description of a function. |
environment | string | Describe whether the function is 1st Gen or 2nd Gen. |
eventTrigger | object | An Eventarc trigger managed by Google Cloud Functions that fires events in response to a condition in another service. (id: EventTrigger) |
kmsKeyName | string | Resource name of a KMS crypto key (managed by the user) used to encrypt/decrypt function resources. It must match the pattern projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} . |
labels | object | Labels associated with this Cloud Function. |
satisfiesPzi | boolean | Output only. Reserved for future use. |
satisfiesPzs | boolean | Output only. Reserved for future use. |
serviceConfig | object | Describes the Service being deployed. Currently deploys services to Cloud Run (fully managed). (id: ServiceConfig) |
state | string | Output only. State of the function. |
stateMessages | array | Output only. State Messages for this Cloud Function. |
updateTime | string (google-datetime) | Output only. The last update timestamp of a Cloud Function. |
upgradeInfo | object | Output only. UpgradeInfo for this Cloud Function (id: UpgradeInfo) |
url | string | Output only. The deployed url for the function. |
Successful response
Name | Datatype | Description |
---|---|---|
name | string | A user-defined name of the function. Function names must be unique globally and match pattern projects/*/locations/*/functions/* |
buildConfig | object | Describes the Build step of the function that builds a container from the given source. (id: BuildConfig) |
createTime | string (google-datetime) | Output only. The create timestamp of a Cloud Function. This is only applicable to 2nd Gen functions. |
description | string | User-provided description of a function. |
environment | string | Describe whether the function is 1st Gen or 2nd Gen. |
eventTrigger | object | An Eventarc trigger managed by Google Cloud Functions that fires events in response to a condition in another service. (id: EventTrigger) |
kmsKeyName | string | Resource name of a KMS crypto key (managed by the user) used to encrypt/decrypt function resources. It must match the pattern projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} . |
labels | object | Labels associated with this Cloud Function. |
satisfiesPzi | boolean | Output only. Reserved for future use. |
satisfiesPzs | boolean | Output only. Reserved for future use. |
serviceConfig | object | Describes the Service being deployed. Currently deploys services to Cloud Run (fully managed). (id: ServiceConfig) |
state | string | Output only. State of the function. |
stateMessages | array | Output only. State Messages for this Cloud Function. |
updateTime | string (google-datetime) | Output only. The last update timestamp of a Cloud Function. |
upgradeInfo | object | Output only. UpgradeInfo for this Cloud Function (id: UpgradeInfo) |
url | string | Output only. The deployed url for the function. |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
get | select | projectsId , locationsId , functionsId | revision | Returns a function with the given name from the requested project. |
list | select | projectsId , locationsId | pageSize , pageToken , filter , orderBy | Returns a list of functions that belong to the requested project. |
create | insert | projectsId , locationsId | functionId | Creates a new function. If a function with the given name already exists in the specified project, the long running operation will return ALREADY_EXISTS error. |
patch | update | projectsId , locationsId , functionsId | updateMask | Updates existing function. |
delete | delete | projectsId , locationsId , functionsId | Deletes a function with the given name from the specified project. If the given function is used by some trigger, the trigger will be updated to remove this function. | |
setup_function_upgrade_config | exec | projectsId , locationsId , functionsId | Creates a 2nd Gen copy of the function configuration based on the 1st Gen function with the given name. This is the first step of the multi step process to upgrade 1st Gen functions to 2nd Gen. Only 2nd Gen configuration is setup as part of this request and traffic continues to be served by 1st Gen. | |
abort_function_upgrade | exec | projectsId , locationsId , functionsId | Aborts generation upgrade process for a function with the given name from the specified project. Deletes all 2nd Gen copy related configuration and resources which were created during the upgrade process. | |
redirect_function_upgrade_traffic | exec | projectsId , locationsId , functionsId | Changes the traffic target of a function from the original 1st Gen function to the 2nd Gen copy. This is the second step of the multi step process to upgrade 1st Gen functions to 2nd Gen. After this operation, all new traffic will be served by 2nd Gen copy. | |
rollback_function_upgrade_traffic | exec | projectsId , locationsId , functionsId | Reverts the traffic target of a function from the 2nd Gen copy to the original 1st Gen function. After this operation, all new traffic would be served by the 1st Gen. | |
commit_function_upgrade | exec | projectsId , locationsId , functionsId | Finalizes the upgrade after which function upgrade can not be rolled back. This is the last step of the multi step process to upgrade 1st Gen functions to 2nd Gen. Deletes all original 1st Gen related configuration and resources. | |
generate_upload_url | exec | projectsId , locationsId | Returns a signed URL for uploading a function source code. For more information about the signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls. Once the function source code upload is complete, the used signed URL should be provided in CreateFunction or UpdateFunction request as a reference to the function source code. When uploading source code to the generated signed URL, please follow these restrictions: * Source file type should be a zip file. * No credentials should be attached - the signed URLs provide access to the target bucket using internal service identity; if credentials were attached, the identity from the credentials would be used, but that identity does not have permissions to upload files to the URL. When making a HTTP PUT request, specify this header: * content-type: application/zip Do not specify this header: * Authorization: Bearer YOUR_TOKEN | |
generate_download_url | exec | projectsId , locationsId , functionsId | Returns a signed URL for downloading deployed function source code. The URL is only valid for a limited period and should be used within 30 minutes of generation. For more information about the signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls | |
detach_function | exec | projectsId , locationsId , functionsId | Detaches 2nd Gen function to Cloud Run function. |
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 |
---|---|---|
functionsId | string | |
locationsId | string | |
projectsId | string | |
filter | string | |
functionId | string | |
orderBy | string | |
pageSize | integer (int32) | |
pageToken | string | |
revision | string | |
updateMask | string (google-fieldmask) |
SELECT
examples
- get
- list
Returns a function with the given name from the requested project.
SELECT
name,
buildConfig,
createTime,
description,
environment,
eventTrigger,
kmsKeyName,
labels,
satisfiesPzi,
satisfiesPzs,
serviceConfig,
state,
stateMessages,
updateTime,
upgradeInfo,
url
FROM google.cloudfunctions.functions
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND functionsId = '{{ functionsId }}' -- required
AND revision = '{{ revision }}';
Returns a list of functions that belong to the requested project.
SELECT
name,
buildConfig,
createTime,
description,
environment,
eventTrigger,
kmsKeyName,
labels,
satisfiesPzi,
satisfiesPzs,
serviceConfig,
state,
stateMessages,
updateTime,
upgradeInfo,
url
FROM google.cloudfunctions.functions
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND pageSize = '{{ pageSize }}'
AND pageToken = '{{ pageToken }}'
AND filter = '{{ filter }}'
AND orderBy = '{{ orderBy }}';
INSERT
examples
- create
- Manifest
Creates a new function. If a function with the given name already exists in the specified project, the long running operation will return ALREADY_EXISTS
error.
INSERT INTO google.cloudfunctions.functions (
data__name,
data__description,
data__buildConfig,
data__serviceConfig,
data__eventTrigger,
data__labels,
data__environment,
data__kmsKeyName,
projectsId,
locationsId,
functionId
)
SELECT
'{{ name }}',
'{{ description }}',
'{{ buildConfig }}',
'{{ serviceConfig }}',
'{{ eventTrigger }}',
'{{ labels }}',
'{{ environment }}',
'{{ kmsKeyName }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ functionId }}'
RETURNING
name,
done,
error,
metadata,
response
;
# Description fields are for documentation purposes
- name: functions
props:
- name: projectsId
value: string
description: Required parameter for the functions resource.
- name: locationsId
value: string
description: Required parameter for the functions resource.
- name: name
value: string
description: >
A user-defined name of the function. Function names must be unique globally and match pattern `projects/*/locations/*/functions/*`
- name: description
value: string
description: >
User-provided description of a function.
- name: buildConfig
value: object
description: >
Describes the Build step of the function that builds a container from the given source.
- name: serviceConfig
value: object
description: >
Describes the Service being deployed. Currently deploys services to Cloud Run (fully managed).
- name: eventTrigger
value: object
description: >
An Eventarc trigger managed by Google Cloud Functions that fires events in response to a condition in another service.
- name: labels
value: object
description: >
Labels associated with this Cloud Function.
- name: environment
value: string
description: >
Describe whether the function is 1st Gen or 2nd Gen.
valid_values: ['ENVIRONMENT_UNSPECIFIED', 'GEN_1', 'GEN_2']
- name: kmsKeyName
value: string
description: >
Resource name of a KMS crypto key (managed by the user) used to encrypt/decrypt function resources. It must match the pattern `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
- name: functionId
value: string
UPDATE
examples
- patch
Updates existing function.
UPDATE google.cloudfunctions.functions
SET
data__name = '{{ name }}',
data__description = '{{ description }}',
data__buildConfig = '{{ buildConfig }}',
data__serviceConfig = '{{ serviceConfig }}',
data__eventTrigger = '{{ eventTrigger }}',
data__labels = '{{ labels }}',
data__environment = '{{ environment }}',
data__kmsKeyName = '{{ kmsKeyName }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND functionsId = '{{ functionsId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
done,
error,
metadata,
response;
DELETE
examples
- delete
Deletes a function with the given name from the specified project. If the given function is used by some trigger, the trigger will be updated to remove this function.
DELETE FROM google.cloudfunctions.functions
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND functionsId = '{{ functionsId }}' --required;
Lifecycle Methods
- setup_function_upgrade_config
- abort_function_upgrade
- redirect_function_upgrade_traffic
- rollback_function_upgrade_traffic
- commit_function_upgrade
- generate_upload_url
- generate_download_url
- detach_function
Creates a 2nd Gen copy of the function configuration based on the 1st Gen function with the given name. This is the first step of the multi step process to upgrade 1st Gen functions to 2nd Gen. Only 2nd Gen configuration is setup as part of this request and traffic continues to be served by 1st Gen.
EXEC google.cloudfunctions.functions.setup_function_upgrade_config
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@functionsId='{{ functionsId }}' --required
@@json=
'{
"triggerServiceAccount": "{{ triggerServiceAccount }}"
}';
Aborts generation upgrade process for a function with the given name from the specified project. Deletes all 2nd Gen copy related configuration and resources which were created during the upgrade process.
EXEC google.cloudfunctions.functions.abort_function_upgrade
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@functionsId='{{ functionsId }}' --required;
Changes the traffic target of a function from the original 1st Gen function to the 2nd Gen copy. This is the second step of the multi step process to upgrade 1st Gen functions to 2nd Gen. After this operation, all new traffic will be served by 2nd Gen copy.
EXEC google.cloudfunctions.functions.redirect_function_upgrade_traffic
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@functionsId='{{ functionsId }}' --required;
Reverts the traffic target of a function from the 2nd Gen copy to the original 1st Gen function. After this operation, all new traffic would be served by the 1st Gen.
EXEC google.cloudfunctions.functions.rollback_function_upgrade_traffic
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@functionsId='{{ functionsId }}' --required;
Finalizes the upgrade after which function upgrade can not be rolled back. This is the last step of the multi step process to upgrade 1st Gen functions to 2nd Gen. Deletes all original 1st Gen related configuration and resources.
EXEC google.cloudfunctions.functions.commit_function_upgrade
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@functionsId='{{ functionsId }}' --required;
Returns a signed URL for uploading a function source code. For more information about the signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls. Once the function source code upload is complete, the used signed URL should be provided in CreateFunction or UpdateFunction request as a reference to the function source code. When uploading source code to the generated signed URL, please follow these restrictions: * Source file type should be a zip file. * No credentials should be attached - the signed URLs provide access to the target bucket using internal service identity; if credentials were attached, the identity from the credentials would be used, but that identity does not have permissions to upload files to the URL. When making a HTTP PUT request, specify this header: * content-type: application/zip
Do not specify this header: * Authorization: Bearer YOUR_TOKEN
EXEC google.cloudfunctions.functions.generate_upload_url
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required
@@json=
'{
"kmsKeyName": "{{ kmsKeyName }}",
"environment": "{{ environment }}"
}';
Returns a signed URL for downloading deployed function source code. The URL is only valid for a limited period and should be used within 30 minutes of generation. For more information about the signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls
EXEC google.cloudfunctions.functions.generate_download_url
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@functionsId='{{ functionsId }}' --required;
Detaches 2nd Gen function to Cloud Run function.
EXEC google.cloudfunctions.functions.detach_function
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@functionsId='{{ functionsId }}' --required;