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,
  "description": string,
  "status": enum(CloudFunctionStatus),
  "entryPoint": string,
  "timeout": string,
  "availableMemoryMb": number,
  "serviceAccountEmail": string,
  "updateTime": string,
  "versionId": string,
  "labels": {
    string: string,
    ...
  },

  // Union field source_code can be only one of the following:
  "sourceArchiveUrl": string,
  "sourceRepository": {
    object(SourceRepository)
  },
  "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/*

description

string

User-provided description of a function.

status

enum(CloudFunctionStatus)

Output only. Status of the function deployment.

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.

serviceAccountEmail

string

Output only. The email of the function's service account.

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)

Beta Feature

The source repository where a function is hosted.

sourceUploadUrl

string

The Google Cloud Storage signed URL used for source uploading, generated by [google.cloud.functions.v1.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 SourceRepository, used to represent parameters related to source repository where a function is hosted.

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

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.

deployedUrl

string

Output only. The URL pointing to the hosted repository where the function were defined at the time of deployment. It always points to a specific commit in the format described above.

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

Required. The type of event to observe. For example: google.storage.object.finalized and google.firebase.analytics.event.log.

Event type consists of three parts: 1. namespace: The domain name of the organization in reverse-domain notation (e.g. acme.net appears as net.acme) and any orginization specific subdivisions. If the organization's top-level domain is com, the top-level domain is ommited (e.g. google.com appears as google). For example, google.storage and google.firebase.analytics. 2. resource type: The type of resource on which event ocurs. For example, the Google Cloud Storage API includes the type object. 3. action: The action that generates the event. For example, actions for a Google Cloud Storage Object include 'finalize' and 'delete'. These parts are lower case and joined by '.'.

resource

string

Required. The resource(s) from which to observe events, for example, projects/_/buckets/myBucket.

Not all syntactically correct values are accepted by all services. For example:

  1. The authorization model must support it. Google Cloud Functions only allows EventTriggers to be deployed that observe resources in the same project as the CloudFunction.
  2. The resource type must match the pattern expected for an eventType. For example, an EventTrigger that has an eventType of "google.pubsub.topic.publish" should have a resource that matches Google Cloud Pub/Sub topics.

Additionally, some services may support short names when creating an EventTrigger. These will always be returned in the normalized "long" format.

See each service's documentation for supported formats.

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
CLOUD_FUNCTION_STATUS_UNSPECIFIED Not specified. Invalid state.
ACTIVE Function has been succesfully deployed and is serving.
OFFLINE Function deployment failed and the function isn’t serving.
DEPLOY_IN_PROGRESS Function is being created or updated.
DELETE_IN_PROGRESS Function is being deleted.
UNKNOWN Function deployment failed and the function serving state is undefined. The function should be updated or deleted to move it out of this state.

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.

patch

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