Skip to main content

functions

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

Overview

Namefunctions
TypeResource
Idgoogle.cloudfunctions.functions

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringA user-defined name of the function. Function names must be unique globally and match pattern projects/*/locations/*/functions/*
buildConfigobjectDescribes the Build step of the function that builds a container from the given source. (id: BuildConfig)
createTimestring (google-datetime)Output only. The create timestamp of a Cloud Function. This is only applicable to 2nd Gen functions.
descriptionstringUser-provided description of a function.
environmentstringDescribe whether the function is 1st Gen or 2nd Gen.
eventTriggerobjectAn Eventarc trigger managed by Google Cloud Functions that fires events in response to a condition in another service. (id: EventTrigger)
kmsKeyNamestringResource 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}.
labelsobjectLabels associated with this Cloud Function.
satisfiesPzibooleanOutput only. Reserved for future use.
satisfiesPzsbooleanOutput only. Reserved for future use.
serviceConfigobjectDescribes the Service being deployed. Currently deploys services to Cloud Run (fully managed). (id: ServiceConfig)
statestringOutput only. State of the function.
stateMessagesarrayOutput only. State Messages for this Cloud Function.
updateTimestring (google-datetime)Output only. The last update timestamp of a Cloud Function.
upgradeInfoobjectOutput only. UpgradeInfo for this Cloud Function (id: UpgradeInfo)
urlstringOutput only. The deployed url for the function.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, functionsIdrevisionReturns a function with the given name from the requested project.
listselectprojectsId, locationsIdpageSize, pageToken, filter, orderByReturns a list of functions that belong to the requested project.
createinsertprojectsId, locationsIdfunctionIdCreates 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.
patchupdateprojectsId, locationsId, functionsIdupdateMaskUpdates existing function.
deletedeleteprojectsId, locationsId, functionsIdDeletes 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_configexecprojectsId, locationsId, functionsIdCreates 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_upgradeexecprojectsId, locationsId, functionsIdAborts 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_trafficexecprojectsId, locationsId, functionsIdChanges 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_trafficexecprojectsId, locationsId, functionsIdReverts 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_upgradeexecprojectsId, locationsId, functionsIdFinalizes 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_urlexecprojectsId, locationsIdReturns 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_urlexecprojectsId, locationsId, functionsIdReturns 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_functionexecprojectsId, locationsId, functionsIdDetaches 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.

NameDatatypeDescription
functionsIdstring
locationsIdstring
projectsIdstring
filterstring
functionIdstring
orderBystring
pageSizeinteger (int32)
pageTokenstring
revisionstring
updateMaskstring (google-fieldmask)

SELECT examples

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

INSERT examples

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
;

UPDATE examples

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

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

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