REST Resource: projects.locations.functions

Resource: CloudFunction

Describes a Cloud Function that contains user computation executed in response to an event. It encapsulate function and triggers configurations.

JSON representation
{
  "name": string,
  "status": enum(CloudFunctionStatus),
  "latestOperation": string,
  "entryPoint": string,
  "timeout": string,
  "availableMemoryMb": number,
  "serviceAccount": string,
  "updateTime": string,
  "versionId": string,
  "labels": {
    string: string,
    ...
  },

  // Union field source_code can be only one of the following:
  "sourceArchiveUrl": string,
  "sourceRepository": {
    object(SourceRepository)
  },
  "sourceRepositoryUrl": string,
  "sourceUploadUrl": string,
  // End of list of possible types for union field source_code.

  // Union field trigger can be only one of the following:
  "httpsTrigger": {
    object(HTTPSTrigger)
  },
  "eventTrigger": {
    object(EventTrigger)
  },
  // End of list of possible types for union field trigger.
}
Fields
name

string

A user-defined name of the function. Function names must be unique globally and match pattern projects/*/locations/*/functions/*

status

enum(CloudFunctionStatus)

Output only. Status of the function deployment.

latestOperation

string

Output only. Name of the most recent operation modifying the function. If the function status is DEPLOYING or DELETING, then it points to the active operation.

entryPoint

string

The name of the function (as defined in source code) that will be executed. Defaults to the resource name suffix, if not specified. For backward compatibility, if function with given name is not found, then the system will try to use function named "function". For Node.js this is name of a function exported by the module specified in source_location.

timeout

string (Duration format)

The function execution timeout. Execution is considered failed and can be terminated if the function is not completed at the end of the timeout period. Defaults to 60 seconds.

A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".

availableMemoryMb

number

The amount of memory in MB available for a function. Defaults to 256MB.

serviceAccount

string

Output only. The service account of the function.

updateTime

string (Timestamp format)

Output only. The last update timestamp of a Cloud Function.

A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

versionId

string (int64 format)

Output only. The version identifier of the Cloud Function. Each deployment attempt results in a new version of a function being created.

labels

map (key: string, value: string)

Labels associated with this Cloud Function.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

Union field source_code. The location of the function source code. source_code can be only one of the following:
sourceArchiveUrl

string

The Google Cloud Storage URL, starting with gs://, pointing to the zip archive which contains the function.

sourceRepository

object(SourceRepository)

The hosted repository where the function is defined.

sourceRepositoryUrl

string

The URL pointing to the hosted repository where the function is defined. There are supported Cloud Source Repository URLs in the following formats:

To refer to a specific commit: https://source.developers.google.com/projects/*/repos/*/revisions/*/paths/* To refer to a moveable alias (branch): https://source.developers.google.com/projects/*/repos/*/moveable-aliases/*/paths/* In particular, to refer to HEAD use master moveable alias. To refer to a specific fixed alias (tag): https://source.developers.google.com/projects/*/repos/*/fixed-aliases/*/paths/*

You may omit paths/* if you want to use the main directory.

sourceUploadUrl

string

The Google Cloud Storage signed URL used for source uploading, generated by [google.cloud.functions.v1beta2.GenerateUploadUrl][]

Union field trigger. An event that triggers the function. trigger can be only one of the following:
httpsTrigger

object(HTTPSTrigger)

An HTTPS endpoint type of source that can be triggered via URL.

eventTrigger

object(EventTrigger)

A source that fires events in response to a condition in another service.

SourceRepository

Describes the location of the function source in a remote repository.

JSON representation
{
  "repositoryUrl": string,
  "sourcePath": string,
  "deployedRevision": string,

  // Union field version can be only one of the following:
  "branch": string,
  "tag": string,
  "revision": string,
  // End of list of possible types for union field version.
}
Fields
repositoryUrl

string

URL to the hosted repository where the function is defined. Only paths in https://source.developers.google.com domain are supported. The path should contain the name of the repository.

sourcePath

string

The path within the repository where the function is defined. The path should point to the directory where Cloud Functions files are located. Use "/" if the function is defined directly in the root directory of a repository.

deployedRevision

string

Output only. The id of the revision that was resolved at the moment of function creation or update. For example when a user deployed from a branch, it will be the revision id of the latest change on this branch at that time. If user deployed from revision then this value will be always equal to the revision specified by the user.

Union field version. The version of a function. Defaults to the latest version of the master branch. version can be only one of the following:
branch

string

The name of the branch from which the function should be fetched.

tag

string

The name of the tag that captures the state of the repository from which the function should be fetched.

revision

string

The id of the revision that captures the state of the repository from which the function should be fetched.

HTTPSTrigger

Describes HTTPSTrigger, could be used to connect web hooks to function.

JSON representation
{
  "url": string,
}
Fields
url

string

Output only. The deployed url for the function.

EventTrigger

Describes EventTrigger, used to request events be sent from another service.

JSON representation
{
  "eventType": string,
  "resource": string,
  "service": string,
  "failurePolicy": {
    object(FailurePolicy)
  },
}
Fields
eventType

string

eventType names contain the service that is sending an event and the kind of event that was fired. Must be of the form providers/*/eventTypes/* e.g. Directly handle a Message published to Google Cloud Pub/Sub providers/cloud.pubsub/eventTypes/topic.publish

 Handle an object changing in Google Cloud Storage
 `providers/cloud.storage/eventTypes/object.change`

 Handle a write to the Firebase Realtime Database
 `providers/google.firebase.database/eventTypes/ref.write`

resource

string

Which instance of the source's service should send events. E.g. for Pub/Sub this would be a Pub/Sub topic at projects/*/topics/*. For Google Cloud Storage this would be a bucket at projects/*/buckets/*. For any source that only supports one instance per-project, this should be the name of the project (projects/*)

service

string

The hostname of the service that should be observed.

If no string is provided, the default service implementing the API will be used. For example, storage.googleapis.com is the default for all event types in the 'google.storage` namespace.

failurePolicy

object(FailurePolicy)

Specifies policy for failed executions.

FailurePolicy

Describes the policy in case of function's execution failure. If empty, then defaults to ignoring failures (i.e. not retrying them).

JSON representation
{
  "retry": {
    object(Retry)
  },
}
Fields
retry

object(Retry)

If specified, then the function will be retried in case of a failure.

Retry

Describes the retry policy in case of function's execution failure. A function execution will be retried on any failure. A failed execution will be retried up to 7 days with an exponential backoff (capped at 10 seconds). Retried execution is charged as any other execution.

CloudFunctionStatus

Describes the current stage of a deployment.

Enums
STATUS_UNSPECIFIED Status not specified.
READY Successfully deployed.
FAILED Not deployed correctly - behavior is undefined. The item should be updated or deleted to move it out of this state.
DEPLOYING Creation or update in progress.
DELETING Deletion in progress.

Methods

call

Invokes synchronously deployed function.

create

Creates a new function.

delete

Deletes a function with the given name from the specified project.

generateDownloadUrl

Returns a signed URL for downloading deployed function source code.

generateUploadUrl

Returns a signed URL for uploading a function source code.

get

Returns a function with the given name from the requested project.

list

Returns a list of functions that belong to the requested project.

update

Updates existing function.

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud Functions