Documentation ¶
Overview ¶
Package functions is an auto-generated package for the Cloud Functions API.
Manages lightweight user-provided functions executed in response to events.
NOTE: This package is in beta. It is not stable, and may be subject to changes.
General documentation ¶
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage ¶
To get started with this package, create a client.
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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.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.
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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &functionspb.CreateFunctionRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/functions/apiv2beta/functionspb#CreateFunctionRequest. } op, err := c.CreateFunction(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context ¶
The ctx passed to NewFunctionClient is used for authentication requests and for 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.
Index ¶
- func DefaultAuthScopes() []string
- type CreateFunctionOperation
- func (op *CreateFunctionOperation) Done() bool
- func (op *CreateFunctionOperation) Metadata() (*functionspb.OperationMetadata, error)
- func (op *CreateFunctionOperation) Name() string
- func (op *CreateFunctionOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*functionspb.Function, error)
- func (op *CreateFunctionOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*functionspb.Function, error)
- type DeleteFunctionOperation
- func (op *DeleteFunctionOperation) Done() bool
- func (op *DeleteFunctionOperation) Metadata() (*functionspb.OperationMetadata, error)
- func (op *DeleteFunctionOperation) Name() string
- func (op *DeleteFunctionOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
- func (op *DeleteFunctionOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
- type FunctionCallOptions
- type FunctionClient
- func (c *FunctionClient) Close() error
- func (c *FunctionClient) Connection() *grpc.ClientConndeprecated
- func (c *FunctionClient) CreateFunction(ctx context.Context, req *functionspb.CreateFunctionRequest, ...) (*CreateFunctionOperation, error)
- func (c *FunctionClient) CreateFunctionOperation(name string) *CreateFunctionOperation
- func (c *FunctionClient) DeleteFunction(ctx context.Context, req *functionspb.DeleteFunctionRequest, ...) (*DeleteFunctionOperation, error)
- func (c *FunctionClient) DeleteFunctionOperation(name string) *DeleteFunctionOperation
- func (c *FunctionClient) GenerateDownloadUrl(ctx context.Context, req *functionspb.GenerateDownloadUrlRequest, ...) (*functionspb.GenerateDownloadUrlResponse, error)
- func (c *FunctionClient) GenerateUploadUrl(ctx context.Context, req *functionspb.GenerateUploadUrlRequest, ...) (*functionspb.GenerateUploadUrlResponse, error)
- func (c *FunctionClient) GetFunction(ctx context.Context, req *functionspb.GetFunctionRequest, ...) (*functionspb.Function, error)
- func (c *FunctionClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
- func (c *FunctionClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, ...) (*longrunningpb.Operation, error)
- func (c *FunctionClient) ListFunctions(ctx context.Context, req *functionspb.ListFunctionsRequest, ...) *FunctionIterator
- func (c *FunctionClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, ...) *LocationIterator
- func (c *FunctionClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, ...) *OperationIterator
- func (c *FunctionClient) ListRuntimes(ctx context.Context, req *functionspb.ListRuntimesRequest, ...) (*functionspb.ListRuntimesResponse, error)
- func (c *FunctionClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
- func (c *FunctionClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, ...) (*iampb.TestIamPermissionsResponse, error)
- func (c *FunctionClient) UpdateFunction(ctx context.Context, req *functionspb.UpdateFunctionRequest, ...) (*UpdateFunctionOperation, error)
- func (c *FunctionClient) UpdateFunctionOperation(name string) *UpdateFunctionOperation
- type FunctionIterator
- type LocationIterator
- type OperationIterator
- type UpdateFunctionOperation
- func (op *UpdateFunctionOperation) Done() bool
- func (op *UpdateFunctionOperation) Metadata() (*functionspb.OperationMetadata, error)
- func (op *UpdateFunctionOperation) Name() string
- func (op *UpdateFunctionOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*functionspb.Function, error)
- func (op *UpdateFunctionOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*functionspb.Function, error)
Examples ¶
- FunctionClient.CreateFunction
- FunctionClient.DeleteFunction
- FunctionClient.GenerateDownloadUrl
- FunctionClient.GenerateUploadUrl
- FunctionClient.GetFunction
- FunctionClient.GetIamPolicy
- FunctionClient.GetOperation
- FunctionClient.ListFunctions
- FunctionClient.ListLocations
- FunctionClient.ListOperations
- FunctionClient.ListRuntimes
- FunctionClient.SetIamPolicy
- FunctionClient.TestIamPermissions
- FunctionClient.UpdateFunction
- NewFunctionClient
- NewFunctionRESTClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type CreateFunctionOperation ¶
type CreateFunctionOperation struct {
// contains filtered or unexported fields
}
CreateFunctionOperation manages a long-running operation from CreateFunction.
func (*CreateFunctionOperation) Done ¶
func (op *CreateFunctionOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*CreateFunctionOperation) Metadata ¶
func (op *CreateFunctionOperation) Metadata() (*functionspb.OperationMetadata, error)
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 ¶
func (op *CreateFunctionOperation) Name() string
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 ¶
func (op *CreateFunctionOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*functionspb.Function, error)
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 and the 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 ¶
func (op *CreateFunctionOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*functionspb.Function, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
type DeleteFunctionOperation ¶
type DeleteFunctionOperation struct {
// contains filtered or unexported fields
}
DeleteFunctionOperation manages a long-running operation from DeleteFunction.
func (*DeleteFunctionOperation) Done ¶
func (op *DeleteFunctionOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*DeleteFunctionOperation) Metadata ¶
func (op *DeleteFunctionOperation) Metadata() (*functionspb.OperationMetadata, error)
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 ¶
func (op *DeleteFunctionOperation) Name() string
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 ¶
func (op *DeleteFunctionOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
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 and the 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 ¶
func (op *DeleteFunctionOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
type FunctionCallOptions ¶
type FunctionCallOptions struct { GetFunction []gax.CallOption ListFunctions []gax.CallOption CreateFunction []gax.CallOption UpdateFunction []gax.CallOption DeleteFunction []gax.CallOption GenerateUploadUrl []gax.CallOption GenerateDownloadUrl []gax.CallOption ListRuntimes []gax.CallOption ListLocations []gax.CallOption GetIamPolicy []gax.CallOption SetIamPolicy []gax.CallOption TestIamPermissions []gax.CallOption GetOperation []gax.CallOption ListOperations []gax.CallOption }
FunctionCallOptions contains the retry settings for each method of FunctionClient.
type FunctionClient ¶
type FunctionClient struct { // The call options for this service. CallOptions *FunctionCallOptions // 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 }
FunctionClient 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.
Google Cloud Functions is used to deploy functions that are executed by Google in response to various events. Data connected with that event is passed to a function as the input data.
A function is a resource which describes a function that should be executed and how it is triggered.
func NewFunctionClient ¶
func NewFunctionClient(ctx context.Context, opts ...option.ClientOption) (*FunctionClient, error)
NewFunctionClient creates a new function service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Google Cloud Functions is used to deploy functions that are executed by Google in response to various events. Data connected with that event is passed to a function as the input data.
A function is a resource which describes a function that should be executed and how it is triggered.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewFunctionRESTClient ¶
func NewFunctionRESTClient(ctx context.Context, opts ...option.ClientOption) (*FunctionClient, error)
NewFunctionRESTClient creates a new function service rest client.
Google Cloud Functions is used to deploy functions that are executed by Google in response to various events. Data connected with that event is passed to a function as the input data.
A function is a resource which describes a function that should be executed and how it is triggered.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" ) func main() { 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_Options c, err := functions.NewFunctionRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*FunctionClient) Close ¶
func (c *FunctionClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*FunctionClient) Connection
deprecated
func (c *FunctionClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*FunctionClient) CreateFunction ¶
func (c *FunctionClient) CreateFunction(ctx context.Context, req *functionspb.CreateFunctionRequest, opts ...gax.CallOption) (*CreateFunctionOperation, error)
CreateFunction 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.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" functionspb "cloud.google.com/go/functions/apiv2beta/functionspb" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &functionspb.CreateFunctionRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/functions/apiv2beta/functionspb#CreateFunctionRequest. } op, err := c.CreateFunction(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FunctionClient) CreateFunctionOperation ¶
func (c *FunctionClient) CreateFunctionOperation(name string) *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 (*FunctionClient) DeleteFunction ¶
func (c *FunctionClient) DeleteFunction(ctx context.Context, req *functionspb.DeleteFunctionRequest, opts ...gax.CallOption) (*DeleteFunctionOperation, error)
DeleteFunction 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.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" functionspb "cloud.google.com/go/functions/apiv2beta/functionspb" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &functionspb.DeleteFunctionRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/functions/apiv2beta/functionspb#DeleteFunctionRequest. } op, err := c.DeleteFunction(ctx, req) if err != nil { // TODO: Handle error. } err = op.Wait(ctx) if err != nil { // TODO: Handle error. } }
Output:
func (*FunctionClient) DeleteFunctionOperation ¶
func (c *FunctionClient) DeleteFunctionOperation(name string) *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 (*FunctionClient) GenerateDownloadUrl ¶
func (c *FunctionClient) GenerateDownloadUrl(ctx context.Context, req *functionspb.GenerateDownloadUrlRequest, opts ...gax.CallOption) (*functionspb.GenerateDownloadUrlResponse, error)
GenerateDownloadUrl 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 (at https://cloud.google.com/storage/docs/access-control/signed-urls)
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" functionspb "cloud.google.com/go/functions/apiv2beta/functionspb" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &functionspb.GenerateDownloadUrlRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/functions/apiv2beta/functionspb#GenerateDownloadUrlRequest. } resp, err := c.GenerateDownloadUrl(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FunctionClient) GenerateUploadUrl ¶
func (c *FunctionClient) GenerateUploadUrl(ctx context.Context, req *functionspb.GenerateUploadUrlRequest, opts ...gax.CallOption) (*functionspb.GenerateUploadUrlResponse, error)
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 (at 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, these two headers need to be specified:
content-type: application/zip
And this header SHOULD NOT be specified:
Authorization: Bearer YOUR_TOKEN
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" functionspb "cloud.google.com/go/functions/apiv2beta/functionspb" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &functionspb.GenerateUploadUrlRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/functions/apiv2beta/functionspb#GenerateUploadUrlRequest. } resp, err := c.GenerateUploadUrl(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FunctionClient) GetFunction ¶
func (c *FunctionClient) GetFunction(ctx context.Context, req *functionspb.GetFunctionRequest, opts ...gax.CallOption) (*functionspb.Function, error)
GetFunction returns a function with the given name from the requested project.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" functionspb "cloud.google.com/go/functions/apiv2beta/functionspb" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &functionspb.GetFunctionRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/functions/apiv2beta/functionspb#GetFunctionRequest. } resp, err := c.GetFunction(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FunctionClient) GetIamPolicy ¶
func (c *FunctionClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
GetIamPolicy gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" iampb "cloud.google.com/go/iam/apiv1/iampb" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FunctionClient) GetOperation ¶
func (c *FunctionClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error)
GetOperation is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FunctionClient) ListFunctions ¶
func (c *FunctionClient) ListFunctions(ctx context.Context, req *functionspb.ListFunctionsRequest, opts ...gax.CallOption) *FunctionIterator
ListFunctions returns a list of functions that belong to the requested project.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" functionspb "cloud.google.com/go/functions/apiv2beta/functionspb" "google.golang.org/api/iterator" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &functionspb.ListFunctionsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/functions/apiv2beta/functionspb#ListFunctionsRequest. } it := c.ListFunctions(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*FunctionClient) ListLocations ¶
func (c *FunctionClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator
ListLocations lists information about the supported locations for this service.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" "google.golang.org/api/iterator" locationpb "google.golang.org/genproto/googleapis/cloud/location" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.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() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*FunctionClient) ListOperations ¶
func (c *FunctionClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator
ListOperations is a utility method from google.longrunning.Operations.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" "google.golang.org/api/iterator" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.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() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*FunctionClient) ListRuntimes ¶
func (c *FunctionClient) ListRuntimes(ctx context.Context, req *functionspb.ListRuntimesRequest, opts ...gax.CallOption) (*functionspb.ListRuntimesResponse, error)
ListRuntimes returns a list of runtimes that are supported for the requested project.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" functionspb "cloud.google.com/go/functions/apiv2beta/functionspb" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &functionspb.ListRuntimesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/functions/apiv2beta/functionspb#ListRuntimesRequest. } resp, err := c.ListRuntimes(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FunctionClient) SetIamPolicy ¶
func (c *FunctionClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED errors.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" iampb "cloud.google.com/go/iam/apiv1/iampb" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FunctionClient) TestIamPermissions ¶
func (c *FunctionClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.
Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may “fail open” without warning.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" iampb "cloud.google.com/go/iam/apiv1/iampb" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.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) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FunctionClient) UpdateFunction ¶
func (c *FunctionClient) UpdateFunction(ctx context.Context, req *functionspb.UpdateFunctionRequest, opts ...gax.CallOption) (*UpdateFunctionOperation, error)
UpdateFunction updates existing function.
Example ¶
package main import ( "context" functions "cloud.google.com/go/functions/apiv2beta" functionspb "cloud.google.com/go/functions/apiv2beta/functionspb" ) func main() { 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_Options c, err := functions.NewFunctionClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &functionspb.UpdateFunctionRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/functions/apiv2beta/functionspb#UpdateFunctionRequest. } op, err := c.UpdateFunction(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*FunctionClient) UpdateFunctionOperation ¶
func (c *FunctionClient) UpdateFunctionOperation(name string) *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.
type FunctionIterator ¶
type FunctionIterator struct { // 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. Response interface{} // 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. InternalFetch func(pageSize int, pageToken string) (results []*functionspb.Function, nextPageToken string, err error) // contains filtered or unexported fields }
FunctionIterator manages a stream of *functionspb.Function.
func (*FunctionIterator) Next ¶
func (it *FunctionIterator) Next() (*functionspb.Function, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*FunctionIterator) PageInfo ¶
func (it *FunctionIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type LocationIterator ¶
type LocationIterator struct { // 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. Response interface{} // 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. InternalFetch func(pageSize int, pageToken string) (results []*locationpb.Location, nextPageToken string, err error) // contains filtered or unexported fields }
LocationIterator manages a stream of *locationpb.Location.
func (*LocationIterator) Next ¶
func (it *LocationIterator) Next() (*locationpb.Location, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. 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.
type OperationIterator ¶
type OperationIterator struct { // 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. Response interface{} // 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. InternalFetch func(pageSize int, pageToken string) (results []*longrunningpb.Operation, nextPageToken string, err error) // contains filtered or unexported fields }
OperationIterator manages a stream of *longrunningpb.Operation.
func (*OperationIterator) Next ¶
func (it *OperationIterator) Next() (*longrunningpb.Operation, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. 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.
type UpdateFunctionOperation ¶
type UpdateFunctionOperation struct {
// contains filtered or unexported fields
}
UpdateFunctionOperation manages a long-running operation from UpdateFunction.
func (*UpdateFunctionOperation) Done ¶
func (op *UpdateFunctionOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*UpdateFunctionOperation) Metadata ¶
func (op *UpdateFunctionOperation) Metadata() (*functionspb.OperationMetadata, error)
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 ¶
func (op *UpdateFunctionOperation) Name() string
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 ¶
func (op *UpdateFunctionOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*functionspb.Function, error)
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 and the 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 ¶
func (op *UpdateFunctionOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*functionspb.Function, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.