Cloud Functions API v1 - Package cloud.google.com/go/functions/apiv1 (v1.19.7)

Note: To get more information about this package, such as access to older versions, viewthis package on pkg.go.dev.

Package functions is an auto-generated package for theCloud Functions API.

Manages lightweight user-provided functions executed in response toevents.

General documentation

For information that is relevant for all client libraries please referencehttps://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on thispage includes:

Example usage

To get started with this package, create a client.

// go get cloud.google.com/go/functions/apiv1@latestctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()

The client will use your default application credentials. Clients should be reused instead of created as needed.The methods of Client are safe for concurrent use by multiple goroutines.The returned client must be Closed when it is done being used.

Using the Client

The following is an example of making an API call with the newly created client, mentioned above.

req:=&functionspb.CallFunctionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/functions/apiv1/functionspb#CallFunctionRequest.}resp,err:=c.CallFunction(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp

Use of Context

The ctx passed to NewCloudFunctionsClient is used for authentication requests andfor creating the underlying connection, but is not used for subsequent calls.Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

Functions

func DefaultAuthScopes

funcDefaultAuthScopes()[]string

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

CloudFunctionIterator

typeCloudFunctionIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*functionspb.CloudFunction,nextPageTokenstring,errerror)// contains filtered or unexported fields}

CloudFunctionIterator manages a stream of *functionspb.CloudFunction.

func (*CloudFunctionIterator) All

func(it*CloudFunctionIterator)All()iter.Seq2[*functionspb.CloudFunction,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*CloudFunctionIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*CloudFunctionIterator) PageInfo

func(it*CloudFunctionIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

CloudFunctionsCallOptions

typeCloudFunctionsCallOptionsstruct{ListFunctions[]gax.CallOptionGetFunction[]gax.CallOptionCreateFunction[]gax.CallOptionUpdateFunction[]gax.CallOptionDeleteFunction[]gax.CallOptionCallFunction[]gax.CallOptionGenerateUploadUrl[]gax.CallOptionGenerateDownloadUrl[]gax.CallOptionSetIamPolicy[]gax.CallOptionGetIamPolicy[]gax.CallOptionTestIamPermissions[]gax.CallOptionListLocations[]gax.CallOptionGetOperation[]gax.CallOptionListOperations[]gax.CallOption}

CloudFunctionsCallOptions contains the retry settings for each method of CloudFunctionsClient.

CloudFunctionsClient

typeCloudFunctionsClientstruct{// The call options for this service.CallOptions*CloudFunctionsCallOptions// LROClient is used internally to handle long-running operations.// It is exposed so that its CallOptions can be modified if required.// Users should not Close this client.LROClient*lroauto.OperationsClient// contains filtered or unexported fields}

CloudFunctionsClient is a client for interacting with Cloud Functions API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

A service that application uses to manipulate triggers and functions.

func NewCloudFunctionsClient

funcNewCloudFunctionsClient(ctxcontext.Context,opts...option.ClientOption)(*CloudFunctionsClient,error)

NewCloudFunctionsClient creates a new cloud functions service client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.

A service that application uses to manipulate triggers and functions.

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}

func NewCloudFunctionsRESTClient

funcNewCloudFunctionsRESTClient(ctxcontext.Context,opts...option.ClientOption)(*CloudFunctionsClient,error)

NewCloudFunctionsRESTClient creates a new cloud functions service rest client.

A service that application uses to manipulate triggers and functions.

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}

func (*CloudFunctionsClient) CallFunction

CallFunction synchronously invokes a deployed Cloud Function. To be used for testingpurposes as very limited traffic is allowed. For more information onthe actual limits, refer toRate Limits (athttps://cloud.google.com/functions/quotas#rate_limits).

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"functionspb"cloud.google.com/go/functions/apiv1/functionspb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&functionspb.CallFunctionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/functions/apiv1/functionspb#CallFunctionRequest.}resp,err:=c.CallFunction(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*CloudFunctionsClient) Close

Close closes the connection to the API service. The user should invoke this whenthe client is no longer required.

func (*CloudFunctionsClient) Connection (deprecated)

func(c*CloudFunctionsClient)Connection()*grpc.ClientConn

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.

func (*CloudFunctionsClient) CreateFunction

CreateFunction creates a new function. If a function with the given name already exists inthe specified project, the long running operation will returnALREADY_EXISTS error.

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"functionspb"cloud.google.com/go/functions/apiv1/functionspb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&functionspb.CreateFunctionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/functions/apiv1/functionspb#CreateFunctionRequest.}op,err:=c.CreateFunction(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*CloudFunctionsClient) CreateFunctionOperation

func(c*CloudFunctionsClient)CreateFunctionOperation(namestring)*CreateFunctionOperation

CreateFunctionOperation returns a new CreateFunctionOperation from a given name.The name must be that of a previously created CreateFunctionOperation, possibly from a different process.

func (*CloudFunctionsClient) DeleteFunction

DeleteFunction deletes a function with the given name from the specified project. If thegiven function is used by some trigger, the trigger will be updated toremove this function.

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"functionspb"cloud.google.com/go/functions/apiv1/functionspb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&functionspb.DeleteFunctionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/functions/apiv1/functionspb#DeleteFunctionRequest.}op,err:=c.DeleteFunction(ctx,req)iferr!=nil{// TODO: Handle error.}err=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}}

func (*CloudFunctionsClient) DeleteFunctionOperation

func(c*CloudFunctionsClient)DeleteFunctionOperation(namestring)*DeleteFunctionOperation

DeleteFunctionOperation returns a new DeleteFunctionOperation from a given name.The name must be that of a previously created DeleteFunctionOperation, possibly from a different process.

func (*CloudFunctionsClient) GenerateDownloadUrl

GenerateDownloadUrl returns a signed URL for downloading deployed function source code.The URL is only valid for a limited period and should be used withinminutes after generation.For more information about the signed URL usage see:https://cloud.google.com/storage/docs/access-control/signed-urls (athttps://cloud.google.com/storage/docs/access-control/signed-urls)

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"functionspb"cloud.google.com/go/functions/apiv1/functionspb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&functionspb.GenerateDownloadUrlRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/functions/apiv1/functionspb#GenerateDownloadUrlRequest.}resp,err:=c.GenerateDownloadUrl(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*CloudFunctionsClient) GenerateUploadUrl

GenerateUploadUrl 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 (athttps://cloud.google.com/storage/docs/access-control/signed-urls).Once the function source code upload is complete, the used signedURL should be provided in CreateFunction or UpdateFunction requestas a reference to the function source code.

When uploading source code to the generated signed URL, please followthese restrictions:

Source file type should be a zip file.Source file size should not exceed 100MB limit.No credentials should be attached - the signed URLs provide access to thetarget bucket using internal service identity; if credentials wereattached, the identity from the credentials would be used, but thatidentity does not have permissions to upload files to the URL.

When making a HTTP PUT request, these two headers need to be specified:

content-type: application/zipx-goog-content-length-range: 0,104857600

And this header SHOULD NOT be specified:

Authorization: Bearer YOUR_TOKEN

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"functionspb"cloud.google.com/go/functions/apiv1/functionspb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&functionspb.GenerateUploadUrlRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/functions/apiv1/functionspb#GenerateUploadUrlRequest.}resp,err:=c.GenerateUploadUrl(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*CloudFunctionsClient) GetFunction

GetFunction returns a function with the given name from the requested project.

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"functionspb"cloud.google.com/go/functions/apiv1/functionspb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&functionspb.GetFunctionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/functions/apiv1/functionspb#GetFunctionRequest.}resp,err:=c.GetFunction(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*CloudFunctionsClient) GetIamPolicy

GetIamPolicy gets the IAM access control policy for a function.Returns an empty policy if the function exists and does not have a policyset.

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"iampb"cloud.google.com/go/iam/apiv1/iampb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&iampb.GetIamPolicyRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.}resp,err:=c.GetIamPolicy(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*CloudFunctionsClient) GetOperation

GetOperation is a utility method from google.longrunning.Operations.

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.GetOperationRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.}resp,err:=c.GetOperation(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*CloudFunctionsClient) ListFunctions

ListFunctions returns a list of functions that belong to the requested project.

Examples

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"functionspb"cloud.google.com/go/functions/apiv1/functionspb""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&functionspb.ListFunctionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/functions/apiv1/functionspb#ListFunctionsRequest.}it:=c.ListFunctions(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*functionspb.ListFunctionsResponse)}}
all
packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"functionspb"cloud.google.com/go/functions/apiv1/functionspb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&functionspb.ListFunctionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/functions/apiv1/functionspb#ListFunctionsRequest.}forresp,err:=rangec.ListFunctions(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*CloudFunctionsClient) ListLocations

ListLocations lists information about the supported locations for this service.

Examples

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1""google.golang.org/api/iterator"locationpb"google.golang.org/genproto/googleapis/cloud/location")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&locationpb.ListLocationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.}it:=c.ListLocations(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*locationpb.ListLocationsResponse)}}
all
packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"locationpb"google.golang.org/genproto/googleapis/cloud/location")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&locationpb.ListLocationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.}forresp,err:=rangec.ListLocations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*CloudFunctionsClient) ListOperations

ListOperations is a utility method from google.longrunning.Operations.

Examples

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb""google.golang.org/api/iterator")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}it:=c.ListOperations(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*longrunningpb.ListOperationsResponse)}}
all
packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"longrunningpb"cloud.google.com/go/longrunning/autogen/longrunningpb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&longrunningpb.ListOperationsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.}forresp,err:=rangec.ListOperations(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*CloudFunctionsClient) SetIamPolicy

SetIamPolicy sets the IAM access control policy on the specified function.Replaces any existing policy.

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"iampb"cloud.google.com/go/iam/apiv1/iampb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&iampb.SetIamPolicyRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.}resp,err:=c.SetIamPolicy(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*CloudFunctionsClient) TestIamPermissions

TestIamPermissions tests the specified permissions against the IAM access control policyfor a function.If the function does not exist, this will return an empty set ofpermissions, not a NOT_FOUND error.

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"iampb"cloud.google.com/go/iam/apiv1/iampb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&iampb.TestIamPermissionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.}resp,err:=c.TestIamPermissions(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*CloudFunctionsClient) UpdateFunction

UpdateFunction updates existing function.

Example

packagemainimport("context"functions"cloud.google.com/go/functions/apiv1"functionspb"cloud.google.com/go/functions/apiv1/functionspb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in://   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=functions.NewCloudFunctionsClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&functionspb.UpdateFunctionRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/functions/apiv1/functionspb#UpdateFunctionRequest.}op,err:=c.UpdateFunction(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*CloudFunctionsClient) UpdateFunctionOperation

func(c*CloudFunctionsClient)UpdateFunctionOperation(namestring)*UpdateFunctionOperation

UpdateFunctionOperation returns a new UpdateFunctionOperation from a given name.The name must be that of a previously created UpdateFunctionOperation, possibly from a different process.

CreateFunctionOperation

typeCreateFunctionOperationstruct{// contains filtered or unexported fields}

CreateFunctionOperation manages a long-running operation from CreateFunction.

func (*CreateFunctionOperation) Done

Done reports whether the long-running operation has completed.

func (*CreateFunctionOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*CreateFunctionOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*CreateFunctionOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*CreateFunctionOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

DeleteFunctionOperation

typeDeleteFunctionOperationstruct{// contains filtered or unexported fields}

DeleteFunctionOperation manages a long-running operation from DeleteFunction.

func (*DeleteFunctionOperation) Done

Done reports whether the long-running operation has completed.

func (*DeleteFunctionOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*DeleteFunctionOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*DeleteFunctionOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*DeleteFunctionOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

LocationIterator

typeLocationIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*locationpb.Location,nextPageTokenstring,errerror)// contains filtered or unexported fields}

LocationIterator manages a stream of *locationpb.Location.

func (*LocationIterator) All

func(it*LocationIterator)All()iter.Seq2[*locationpb.Location,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*LocationIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*LocationIterator) PageInfo

func(it*LocationIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

OperationIterator

typeOperationIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*longrunningpb.Operation,nextPageTokenstring,errerror)// contains filtered or unexported fields}

OperationIterator manages a stream of *longrunningpb.Operation.

func (*OperationIterator) All

func(it*OperationIterator)All()iter.Seq2[*longrunningpb.Operation,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*OperationIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*OperationIterator) PageInfo

func(it*OperationIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

UpdateFunctionOperation

typeUpdateFunctionOperationstruct{// contains filtered or unexported fields}

UpdateFunctionOperation manages a long-running operation from UpdateFunction.

func (*UpdateFunctionOperation) Done

Done reports whether the long-running operation has completed.

func (*UpdateFunctionOperation) Metadata

Metadata returns metadata associated with the long-running operation.Metadata itself does not contact the server, but Poll does.To get the latest metadata, call this method after a successful call to Poll.If the metadata is not available, the returned metadata and error are both nil.

func (*UpdateFunctionOperation) Name

Name returns the name of the long-running operation.The name is assigned by the server and is unique within the service from which the operation is created.

func (*UpdateFunctionOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds andthe operation has completed with failure, the error is returned and op.Done will return true.If Poll succeeds and the operation has completed successfully,op.Done will return true, and the response of the operation is returned.If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*UpdateFunctionOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-30 UTC.