Class v1.CloudFunctionsServiceClient (3.1.0)

A service that application uses to manipulate triggers and functions. v1

Package

@google-cloud/functions

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of CloudFunctionsServiceClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new CloudFunctionsServiceClient({fallback: true}, gax); ```

Properties

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

auth

auth: gax.GoogleAuth;

cloudFunctionsServiceStub

cloudFunctionsServiceStub?: Promise<{
        [name: string]: Function;
    }>;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

locationsClient

locationsClient: LocationsClient;

operationsClient

operationsClient: gax.OperationsClient;

pathTemplates

pathTemplates: {
        [name: string]: gax.PathTemplate;
    };

port

static get port(): number;

The port for this API service.

scopes

static get scopes(): string[];

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static get servicePath(): string;

The DNS address for this API service.

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

callFunction(request, options)

callFunction(request?: protos.google.cloud.functions.v1.ICallFunctionRequest, options?: CallOptions): Promise<[
        protos.google.cloud.functions.v1.ICallFunctionResponse,
        protos.google.cloud.functions.v1.ICallFunctionRequest | undefined,
        {} | undefined
    ]>;

Synchronously invokes a deployed Cloud Function. To be used for testing purposes as very limited traffic is allowed. For more information on the actual limits, refer to [Rate Limits](https://cloud.google.com/functions/quotas#rate_limits).

Parameters
NameDescription
request ICallFunctionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.functions.v1.ICallFunctionResponse, protos.google.cloud.functions.v1.ICallFunctionRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing CallFunctionResponse. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The name of the function to be called.
   */
  // const name = 'abc123'
  /**
   *  Required. Input to be passed to the function.
   */
  // const data = 'abc123'

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callCallFunction() {
    // Construct request
    const request = {
      name,
      data,
    };

    // Run request
    const response = await functionsClient.callFunction(request);
    console.log(response);
  }

  callCallFunction();

callFunction(request, options, callback)

callFunction(request: protos.google.cloud.functions.v1.ICallFunctionRequest, options: CallOptions, callback: Callback<protos.google.cloud.functions.v1.ICallFunctionResponse, protos.google.cloud.functions.v1.ICallFunctionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICallFunctionRequest
options CallOptions
callback Callback<protos.google.cloud.functions.v1.ICallFunctionResponse, protos.google.cloud.functions.v1.ICallFunctionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

callFunction(request, callback)

callFunction(request: protos.google.cloud.functions.v1.ICallFunctionRequest, callback: Callback<protos.google.cloud.functions.v1.ICallFunctionResponse, protos.google.cloud.functions.v1.ICallFunctionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICallFunctionRequest
callback Callback<protos.google.cloud.functions.v1.ICallFunctionResponse, protos.google.cloud.functions.v1.ICallFunctionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

cancelOperation(request, options, callback)

cancelOperation(request: protos.google.longrunning.CancelOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>, callback?: Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>): Promise<protos.google.protobuf.Empty>;

Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an value with a of 1, corresponding to Code.CANCELLED.

Parameters
NameDescription
request CancelOperationRequest

The request object that will be sent.

options CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>

The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Returns
TypeDescription
Promise<protos.google.protobuf.Empty>
Example

const client = longrunning.operationsClient();
await client.cancelOperation({name: ''});

checkCreateFunctionProgress(name)

checkCreateFunctionProgress(name: string): Promise<LROperation<protos.google.cloud.functions.v1.CloudFunction, protos.google.cloud.functions.v1.OperationMetadataV1>>;

Check the status of the long running operation returned by createFunction().

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.cloud.functions.v1.CloudFunction, protos.google.cloud.functions.v1.OperationMetadataV1>>

{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The project and location in which the function should be created,
   *  specified in the format `projects/* /locations/*`
   */
  // const location = 'abc123'
  /**
   *  Required. Function to be created.
   */
  // const function = {}

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callCreateFunction() {
    // Construct request
    const request = {
      location,
      function1,
    };

    // Run request
    const [operation] = await functionsClient.createFunction(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callCreateFunction();

checkDeleteFunctionProgress(name)

checkDeleteFunctionProgress(name: string): Promise<LROperation<protos.google.protobuf.Empty, protos.google.cloud.functions.v1.OperationMetadataV1>>;

Check the status of the long running operation returned by deleteFunction().

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.protobuf.Empty, protos.google.cloud.functions.v1.OperationMetadataV1>>

{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The name of the function which should be deleted.
   */
  // const name = 'abc123'

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callDeleteFunction() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const [operation] = await functionsClient.deleteFunction(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteFunction();

checkUpdateFunctionProgress(name)

checkUpdateFunctionProgress(name: string): Promise<LROperation<protos.google.cloud.functions.v1.CloudFunction, protos.google.cloud.functions.v1.OperationMetadataV1>>;

Check the status of the long running operation returned by updateFunction().

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.cloud.functions.v1.CloudFunction, protos.google.cloud.functions.v1.OperationMetadataV1>>

{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. New version of the function.
   */
  // const function = {}
  /**
   *  Required. The list of fields in `CloudFunction` that have to be updated.
   */
  // const updateMask = {}

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callUpdateFunction() {
    // Construct request
    const request = {
      function1,
    };

    // Run request
    const [operation] = await functionsClient.updateFunction(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callUpdateFunction();

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
TypeDescription
Promise<void>

{Promise} A promise that resolves when the client is closed.

cloudFunctionPath(project, location, functionParam)

cloudFunctionPath(project: string, location: string, functionParam: string): string;

Return a fully-qualified cloudFunction resource name string.

Parameters
NameDescription
project string
location string
functionParam string
Returns
TypeDescription
string

{string} Resource name string.

createFunction(request, options)

createFunction(request?: protos.google.cloud.functions.v1.ICreateFunctionRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

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.

Parameters
NameDescription
request ICreateFunctionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The project and location in which the function should be created,
   *  specified in the format `projects/* /locations/*`
   */
  // const location = 'abc123'
  /**
   *  Required. Function to be created.
   */
  // const function = {}

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callCreateFunction() {
    // Construct request
    const request = {
      location,
      function1,
    };

    // Run request
    const [operation] = await functionsClient.createFunction(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callCreateFunction();

createFunction(request, options, callback)

createFunction(request: protos.google.cloud.functions.v1.ICreateFunctionRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateFunctionRequest
options CallOptions
callback Callback<LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createFunction(request, callback)

createFunction(request: protos.google.cloud.functions.v1.ICreateFunctionRequest, callback: Callback<LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateFunctionRequest
callback Callback<LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

cryptoKeyPath(project, location, keyRing, cryptoKey)

cryptoKeyPath(project: string, location: string, keyRing: string, cryptoKey: string): string;

Return a fully-qualified cryptoKey resource name string.

Parameters
NameDescription
project string
location string
keyRing string
cryptoKey string
Returns
TypeDescription
string

{string} Resource name string.

deleteFunction(request, options)

deleteFunction(request?: protos.google.cloud.functions.v1.IDeleteFunctionRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.protobuf.IEmpty, protos.google.cloud.functions.v1.IOperationMetadataV1>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

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.

Parameters
NameDescription
request IDeleteFunctionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.protobuf.IEmpty, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The name of the function which should be deleted.
   */
  // const name = 'abc123'

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callDeleteFunction() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const [operation] = await functionsClient.deleteFunction(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteFunction();

deleteFunction(request, options, callback)

deleteFunction(request: protos.google.cloud.functions.v1.IDeleteFunctionRequest, options: CallOptions, callback: Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteFunctionRequest
options CallOptions
callback Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteFunction(request, callback)

deleteFunction(request: protos.google.cloud.functions.v1.IDeleteFunctionRequest, callback: Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteFunctionRequest
callback Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteOperation(request, options, callback)

deleteOperation(request: protos.google.longrunning.DeleteOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>): Promise<protos.google.protobuf.Empty>;

Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED.

Parameters
NameDescription
request DeleteOperationRequest

The request object that will be sent.

options CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>

The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Returns
TypeDescription
Promise<protos.google.protobuf.Empty>
Example

const client = longrunning.operationsClient();
await client.deleteOperation({name: ''});

generateDownloadUrl(request, options)

generateDownloadUrl(request?: protos.google.cloud.functions.v1.IGenerateDownloadUrlRequest, options?: CallOptions): Promise<[
        protos.google.cloud.functions.v1.IGenerateDownloadUrlResponse,
        protos.google.cloud.functions.v1.IGenerateDownloadUrlRequest | undefined,
        {} | undefined
    ]>;

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

Parameters
NameDescription
request IGenerateDownloadUrlRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.functions.v1.IGenerateDownloadUrlResponse, protos.google.cloud.functions.v1.IGenerateDownloadUrlRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing GenerateDownloadUrlResponse. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  The name of function for which source code Google Cloud Storage signed
   *  URL should be generated.
   */
  // const name = 'abc123'
  /**
   *  The optional version of function. If not set, default, current version
   *  is used.
   */
  // const versionId = 1234

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callGenerateDownloadUrl() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await functionsClient.generateDownloadUrl(request);
    console.log(response);
  }

  callGenerateDownloadUrl();

generateDownloadUrl(request, options, callback)

generateDownloadUrl(request: protos.google.cloud.functions.v1.IGenerateDownloadUrlRequest, options: CallOptions, callback: Callback<protos.google.cloud.functions.v1.IGenerateDownloadUrlResponse, protos.google.cloud.functions.v1.IGenerateDownloadUrlRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGenerateDownloadUrlRequest
options CallOptions
callback Callback<protos.google.cloud.functions.v1.IGenerateDownloadUrlResponse, protos.google.cloud.functions.v1.IGenerateDownloadUrlRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

generateDownloadUrl(request, callback)

generateDownloadUrl(request: protos.google.cloud.functions.v1.IGenerateDownloadUrlRequest, callback: Callback<protos.google.cloud.functions.v1.IGenerateDownloadUrlResponse, protos.google.cloud.functions.v1.IGenerateDownloadUrlRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGenerateDownloadUrlRequest
callback Callback<protos.google.cloud.functions.v1.IGenerateDownloadUrlResponse, protos.google.cloud.functions.v1.IGenerateDownloadUrlRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

generateUploadUrl(request, options)

generateUploadUrl(request?: protos.google.cloud.functions.v1.IGenerateUploadUrlRequest, options?: CallOptions): Promise<[
        protos.google.cloud.functions.v1.IGenerateUploadUrlResponse,
        protos.google.cloud.functions.v1.IGenerateUploadUrlRequest | undefined,
        {} | undefined
    ]>;

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. 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. * Source file size should not exceed 100MB limit. * 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 * x-goog-content-length-range: 0,104857600

And this header SHOULD NOT be specified:

* Authorization: Bearer YOUR_TOKEN

Parameters
NameDescription
request IGenerateUploadUrlRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.functions.v1.IGenerateUploadUrlResponse, protos.google.cloud.functions.v1.IGenerateUploadUrlRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing GenerateUploadUrlResponse. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  The project and location in which the Google Cloud Storage signed URL
   *  should be generated, specified in the format `projects/* /locations/*`.
   */
  // const parent = 'abc123'
  /**
   *  Resource name of a KMS crypto key (managed by the user) used to
   *  encrypt/decrypt function source code objects in intermediate Cloud Storage
   *  buckets. When you generate an upload url and upload your source code, it
   *  gets copied to an intermediate Cloud Storage bucket. The source code is
   *  then copied to a versioned directory in the sources bucket in the consumer
   *  project during the function deployment.
   *  It must match the pattern
   *  `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
   *  The Google Cloud Functions service account
   *  (service-{project_number}@gcf-admin-robot.iam.gserviceaccount.com) must be
   *  granted the role 'Cloud KMS CryptoKey Encrypter/Decrypter
   *  (roles/cloudkms.cryptoKeyEncrypterDecrypter)' on the
   *  Key/KeyRing/Project/Organization (least access preferred). GCF will
   *  delegate access to the Google Storage service account in the internal
   *  project.
   */
  // const kmsKeyName = 'abc123'

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callGenerateUploadUrl() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await functionsClient.generateUploadUrl(request);
    console.log(response);
  }

  callGenerateUploadUrl();

generateUploadUrl(request, options, callback)

generateUploadUrl(request: protos.google.cloud.functions.v1.IGenerateUploadUrlRequest, options: CallOptions, callback: Callback<protos.google.cloud.functions.v1.IGenerateUploadUrlResponse, protos.google.cloud.functions.v1.IGenerateUploadUrlRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGenerateUploadUrlRequest
options CallOptions
callback Callback<protos.google.cloud.functions.v1.IGenerateUploadUrlResponse, protos.google.cloud.functions.v1.IGenerateUploadUrlRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

generateUploadUrl(request, callback)

generateUploadUrl(request: protos.google.cloud.functions.v1.IGenerateUploadUrlRequest, callback: Callback<protos.google.cloud.functions.v1.IGenerateUploadUrlResponse, protos.google.cloud.functions.v1.IGenerateUploadUrlRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGenerateUploadUrlRequest
callback Callback<protos.google.cloud.functions.v1.IGenerateUploadUrlResponse, protos.google.cloud.functions.v1.IGenerateUploadUrlRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getFunction(request, options)

getFunction(request?: protos.google.cloud.functions.v1.IGetFunctionRequest, options?: CallOptions): Promise<[
        protos.google.cloud.functions.v1.ICloudFunction,
        protos.google.cloud.functions.v1.IGetFunctionRequest | undefined,
        {} | undefined
    ]>;

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

Parameters
NameDescription
request IGetFunctionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IGetFunctionRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The name of the function which details should be obtained.
   */
  // const name = 'abc123'
  /**
   *  Optional. The optional version of the function whose details should be
   *  obtained. The version of a 1st Gen function is an integer that starts from
   *  1 and gets incremented on redeployments. Each deployment creates a config
   *  version of the underlying function. GCF may keep historical configs for old
   *  versions. This field can be specified to fetch the historical configs.
   *  Leave it blank or set to 0 to get the latest version of the function.
   */
  // const versionId = 1234

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callGetFunction() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await functionsClient.getFunction(request);
    console.log(response);
  }

  callGetFunction();

getFunction(request, options, callback)

getFunction(request: protos.google.cloud.functions.v1.IGetFunctionRequest, options: CallOptions, callback: Callback<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IGetFunctionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetFunctionRequest
options CallOptions
callback Callback<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IGetFunctionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getFunction(request, callback)

getFunction(request: protos.google.cloud.functions.v1.IGetFunctionRequest, callback: Callback<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IGetFunctionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetFunctionRequest
callback Callback<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IGetFunctionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getIamPolicy(request, options)

getIamPolicy(request?: protos.google.iam.v1.IGetIamPolicyRequest, options?: CallOptions): Promise<[
        protos.google.iam.v1.IPolicy,
        protos.google.iam.v1.IGetIamPolicyRequest | undefined,
        {} | undefined
    ]>;

Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set.

Parameters
NameDescription
request IGetIamPolicyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Policy. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  REQUIRED: The resource for which the policy is being requested.
   *  See the operation documentation for the appropriate value for this field.
   */
  // const resource = 'abc123'
  /**
   *  OPTIONAL: A `GetPolicyOptions` object for specifying options to
   *  `GetIamPolicy`.
   */
  // const options = {}

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callGetIamPolicy() {
    // Construct request
    const request = {
      resource,
    };

    // Run request
    const response = await functionsClient.getIamPolicy(request);
    console.log(response);
  }

  callGetIamPolicy();

getIamPolicy(request, options, callback)

getIamPolicy(request: protos.google.iam.v1.IGetIamPolicyRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetIamPolicyRequest
options CallOptions
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getIamPolicy(request, callback)

getIamPolicy(request: protos.google.iam.v1.IGetIamPolicyRequest, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetIamPolicyRequest
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getLocation(request, options, callback)

getLocation(request: LocationProtos.google.cloud.location.IGetLocationRequest, options?: gax.CallOptions | Callback<LocationProtos.google.cloud.location.ILocation, LocationProtos.google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>, callback?: Callback<LocationProtos.google.cloud.location.ILocation, LocationProtos.google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>): Promise<LocationProtos.google.cloud.location.ILocation>;

Gets information about a location.

Parameters
NameDescription
request LocationProtos.google.cloud.location.IGetLocationRequest

The request object that will be sent.

options CallOptions | Callback<google.cloud.location.ILocation, google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>

Call options. See CallOptions for more details.

callback Callback<google.cloud.location.ILocation, google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
Promise<google.cloud.location.ILocation>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

const [response] = await client.getLocation(request);

getOperation(request, options, callback)

getOperation(request: protos.google.longrunning.GetOperationRequest, options?: gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>): Promise<[protos.google.longrunning.Operation]>;

Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.

Parameters
NameDescription
request GetOperationRequest

The request object that will be sent.

options CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing . {Promise} - The promise which resolves to an array. The first element of the array is an object representing . The promise has a method named "cancel" which cancels the ongoing API call.

Returns
TypeDescription
Promise<[protos.google.longrunning.Operation]>
Example

const client = longrunning.operationsClient();
const name = '';
const [response] = await client.getOperation({name});
// doThingsWith(response)

getProjectId()

getProjectId(): Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
NameDescription
callback Callback<string, undefined, undefined>
Returns
TypeDescription
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
TypeDescription
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

listFunctions(request, options)

listFunctions(request?: protos.google.cloud.functions.v1.IListFunctionsRequest, options?: CallOptions): Promise<[
        protos.google.cloud.functions.v1.ICloudFunction[],
        protos.google.cloud.functions.v1.IListFunctionsRequest | null,
        protos.google.cloud.functions.v1.IListFunctionsResponse
    ]>;

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

Parameters
NameDescription
request IListFunctionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.functions.v1.ICloudFunction[], protos.google.cloud.functions.v1.IListFunctionsRequest | null, protos.google.cloud.functions.v1.IListFunctionsResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listFunctionsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listFunctions(request, options, callback)

listFunctions(request: protos.google.cloud.functions.v1.IListFunctionsRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.functions.v1.IListFunctionsRequest, protos.google.cloud.functions.v1.IListFunctionsResponse | null | undefined, protos.google.cloud.functions.v1.ICloudFunction>): void;
Parameters
NameDescription
request IListFunctionsRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.functions.v1.IListFunctionsRequest, protos.google.cloud.functions.v1.IListFunctionsResponse | null | undefined, protos.google.cloud.functions.v1.ICloudFunction>
Returns
TypeDescription
void

listFunctions(request, callback)

listFunctions(request: protos.google.cloud.functions.v1.IListFunctionsRequest, callback: PaginationCallback<protos.google.cloud.functions.v1.IListFunctionsRequest, protos.google.cloud.functions.v1.IListFunctionsResponse | null | undefined, protos.google.cloud.functions.v1.ICloudFunction>): void;
Parameters
NameDescription
request IListFunctionsRequest
callback PaginationCallback<protos.google.cloud.functions.v1.IListFunctionsRequest, protos.google.cloud.functions.v1.IListFunctionsResponse | null | undefined, protos.google.cloud.functions.v1.ICloudFunction>
Returns
TypeDescription
void

listFunctionsAsync(request, options)

listFunctionsAsync(request?: protos.google.cloud.functions.v1.IListFunctionsRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.functions.v1.ICloudFunction>;

Equivalent to listFunctions, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request IListFunctionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.functions.v1.ICloudFunction>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  The project and location from which the function should be listed,
   *  specified in the format `projects/* /locations/*`
   *  If you want to list functions in all locations, use "-" in place of a
   *  location. When listing functions in all locations, if one or more
   *  location(s) are unreachable, the response will contain functions from all
   *  reachable locations along with the names of any unreachable locations.
   */
  // const parent = 'abc123'
  /**
   *  Maximum number of functions to return per call.
   */
  // const pageSize = 1234
  /**
   *  The value returned by the last
   *  `ListFunctionsResponse`; indicates that
   *  this is a continuation of a prior `ListFunctions` call, and that the
   *  system should return the next page of data.
   */
  // const pageToken = 'abc123'

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callListFunctions() {
    // Construct request
    const request = {
    };

    // Run request
    const iterable = await functionsClient.listFunctionsAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListFunctions();

listFunctionsStream(request, options)

listFunctionsStream(request?: protos.google.cloud.functions.v1.IListFunctionsRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request IListFunctionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listFunctionsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listLocationsAsync(request, options)

listLocationsAsync(request: LocationProtos.google.cloud.location.IListLocationsRequest, options?: CallOptions): AsyncIterable<LocationProtos.google.cloud.location.ILocation>;

Lists information about the supported locations for this service. Returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request LocationProtos.google.cloud.location.IListLocationsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<google.cloud.location.ILocation>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

const iterable = client.listLocationsAsync(request);
for await (const response of iterable) {
  // process response
}

listOperationsAsync(request, options)

listOperationsAsync(request: protos.google.longrunning.ListOperationsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.longrunning.ListOperationsResponse>;

Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED. Returns an iterable object.

For-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters
NameDescription
request ListOperationsRequest

The request object that will be sent.

options CallOptions

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Returns
TypeDescription
AsyncIterable<protos.google.longrunning.ListOperationsResponse>

{Object} An iterable Object that conforms to iteration protocols.

Example

const client = longrunning.operationsClient();
for await (const response of client.listOperationsAsync(request));
// doThingsWith(response)

locationPath(project, location)

locationPath(project: string, location: string): string;

Return a fully-qualified location resource name string.

Parameters
NameDescription
project string
location string
Returns
TypeDescription
string

{string} Resource name string.

matchCryptoKeyFromCryptoKeyName(cryptoKeyName)

matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string): string | number;

Parse the crypto_key from CryptoKey resource.

Parameter
NameDescription
cryptoKeyName string

A fully-qualified path representing CryptoKey resource.

Returns
TypeDescription
string | number

{string} A string representing the crypto_key.

matchFunctionFromCloudFunctionName(cloudFunctionName)

matchFunctionFromCloudFunctionName(cloudFunctionName: string): string | number;

Parse the function from CloudFunction resource.

Parameter
NameDescription
cloudFunctionName string

A fully-qualified path representing CloudFunction resource.

Returns
TypeDescription
string | number

{string} A string representing the function.

matchKeyRingFromCryptoKeyName(cryptoKeyName)

matchKeyRingFromCryptoKeyName(cryptoKeyName: string): string | number;

Parse the key_ring from CryptoKey resource.

Parameter
NameDescription
cryptoKeyName string

A fully-qualified path representing CryptoKey resource.

Returns
TypeDescription
string | number

{string} A string representing the key_ring.

matchLocationFromCloudFunctionName(cloudFunctionName)

matchLocationFromCloudFunctionName(cloudFunctionName: string): string | number;

Parse the location from CloudFunction resource.

Parameter
NameDescription
cloudFunctionName string

A fully-qualified path representing CloudFunction resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchLocationFromCryptoKeyName(cryptoKeyName)

matchLocationFromCryptoKeyName(cryptoKeyName: string): string | number;

Parse the location from CryptoKey resource.

Parameter
NameDescription
cryptoKeyName string

A fully-qualified path representing CryptoKey resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchLocationFromLocationName(locationName)

matchLocationFromLocationName(locationName: string): string | number;

Parse the location from Location resource.

Parameter
NameDescription
locationName string

A fully-qualified path representing Location resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchLocationFromRepositoryName(repositoryName)

matchLocationFromRepositoryName(repositoryName: string): string | number;

Parse the location from Repository resource.

Parameter
NameDescription
repositoryName string

A fully-qualified path representing Repository resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchProjectFromCloudFunctionName(cloudFunctionName)

matchProjectFromCloudFunctionName(cloudFunctionName: string): string | number;

Parse the project from CloudFunction resource.

Parameter
NameDescription
cloudFunctionName string

A fully-qualified path representing CloudFunction resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromCryptoKeyName(cryptoKeyName)

matchProjectFromCryptoKeyName(cryptoKeyName: string): string | number;

Parse the project from CryptoKey resource.

Parameter
NameDescription
cryptoKeyName string

A fully-qualified path representing CryptoKey resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromLocationName(locationName)

matchProjectFromLocationName(locationName: string): string | number;

Parse the project from Location resource.

Parameter
NameDescription
locationName string

A fully-qualified path representing Location resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromRepositoryName(repositoryName)

matchProjectFromRepositoryName(repositoryName: string): string | number;

Parse the project from Repository resource.

Parameter
NameDescription
repositoryName string

A fully-qualified path representing Repository resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchRepositoryFromRepositoryName(repositoryName)

matchRepositoryFromRepositoryName(repositoryName: string): string | number;

Parse the repository from Repository resource.

Parameter
NameDescription
repositoryName string

A fully-qualified path representing Repository resource.

Returns
TypeDescription
string | number

{string} A string representing the repository.

repositoryPath(project, location, repository)

repositoryPath(project: string, location: string, repository: string): string;

Return a fully-qualified repository resource name string.

Parameters
NameDescription
project string
location string
repository string
Returns
TypeDescription
string

{string} Resource name string.

setIamPolicy(request, options)

setIamPolicy(request?: protos.google.iam.v1.ISetIamPolicyRequest, options?: CallOptions): Promise<[
        protos.google.iam.v1.IPolicy,
        protos.google.iam.v1.ISetIamPolicyRequest | undefined,
        {} | undefined
    ]>;

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

Parameters
NameDescription
request ISetIamPolicyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Policy. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  REQUIRED: The resource for which the policy is being specified.
   *  See the operation documentation for the appropriate value for this field.
   */
  // const resource = 'abc123'
  /**
   *  REQUIRED: The complete policy to be applied to the `resource`. The size of
   *  the policy is limited to a few 10s of KB. An empty policy is a
   *  valid policy but certain Cloud Platform services (such as Projects)
   *  might reject them.
   */
  // const policy = {}
  /**
   *  OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
   *  the fields in the mask will be modified. If no mask is provided, the
   *  following default mask is used:
   *  `paths: "bindings, etag"`
   */
  // const updateMask = {}

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callSetIamPolicy() {
    // Construct request
    const request = {
      resource,
      policy,
    };

    // Run request
    const response = await functionsClient.setIamPolicy(request);
    console.log(response);
  }

  callSetIamPolicy();

setIamPolicy(request, options, callback)

setIamPolicy(request: protos.google.iam.v1.ISetIamPolicyRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ISetIamPolicyRequest
options CallOptions
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

setIamPolicy(request, callback)

setIamPolicy(request: protos.google.iam.v1.ISetIamPolicyRequest, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ISetIamPolicyRequest
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

testIamPermissions(request, options)

testIamPermissions(request?: protos.google.iam.v1.ITestIamPermissionsRequest, options?: CallOptions): Promise<[
        protos.google.iam.v1.ITestIamPermissionsResponse,
        protos.google.iam.v1.ITestIamPermissionsRequest | undefined,
        {} | undefined
    ]>;

Tests the specified permissions against the IAM access control policy for a function. If the function does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

Parameters
NameDescription
request ITestIamPermissionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing TestIamPermissionsResponse. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  REQUIRED: The resource for which the policy detail is being requested.
   *  See the operation documentation for the appropriate value for this field.
   */
  // const resource = 'abc123'
  /**
   *  The set of permissions to check for the `resource`. Permissions with
   *  wildcards (such as '*' or 'storage.*') are not allowed. For more
   *  information see
   *  IAM Overview (https://cloud.google.com/iam/docs/overview#permissions).
   */
  // const permissions = ['abc','def']

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callTestIamPermissions() {
    // Construct request
    const request = {
      resource,
      permissions,
    };

    // Run request
    const response = await functionsClient.testIamPermissions(request);
    console.log(response);
  }

  callTestIamPermissions();

testIamPermissions(request, options, callback)

testIamPermissions(request: protos.google.iam.v1.ITestIamPermissionsRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ITestIamPermissionsRequest
options CallOptions
callback Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

testIamPermissions(request, callback)

testIamPermissions(request: protos.google.iam.v1.ITestIamPermissionsRequest, callback: Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ITestIamPermissionsRequest
callback Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

updateFunction(request, options)

updateFunction(request?: protos.google.cloud.functions.v1.IUpdateFunctionRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Updates existing function.

Parameters
NameDescription
request IUpdateFunctionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. New version of the function.
   */
  // const function = {}
  /**
   *  Required. The list of fields in `CloudFunction` that have to be updated.
   */
  // const updateMask = {}

  // Imports the Functions library
  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;

  // Instantiates a client
  const functionsClient = new CloudFunctionsServiceClient();

  async function callUpdateFunction() {
    // Construct request
    const request = {
      function1,
    };

    // Run request
    const [operation] = await functionsClient.updateFunction(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callUpdateFunction();

updateFunction(request, options, callback)

updateFunction(request: protos.google.cloud.functions.v1.IUpdateFunctionRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdateFunctionRequest
options CallOptions
callback Callback<LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

updateFunction(request, callback)

updateFunction(request: protos.google.cloud.functions.v1.IUpdateFunctionRequest, callback: Callback<LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdateFunctionRequest
callback Callback<LROperation<protos.google.cloud.functions.v1.ICloudFunction, protos.google.cloud.functions.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void