diff --git a/packages/google-cloud-functions/protos/google/cloud/functions/v2/functions.proto b/packages/google-cloud-functions/protos/google/cloud/functions/v2/functions.proto index a22047aa01a..8b29cd4976b 100644 --- a/packages/google-cloud-functions/protos/google/cloud/functions/v2/functions.proto +++ b/packages/google-cloud-functions/protos/google/cloud/functions/v2/functions.proto @@ -22,6 +22,7 @@ import "google/api/field_behavior.proto"; import "google/api/resource.proto"; import "google/longrunning/operations.proto"; import "google/protobuf/any.proto"; +import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/timestamp.proto"; @@ -75,7 +76,8 @@ option (google.api.resource_definition) = { // executed and how it is triggered. service FunctionService { option (google.api.default_host) = "cloudfunctions.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; // Returns a function with the given name from the requested project. rpc GetFunction(GetFunctionRequest) returns (Function) { @@ -96,7 +98,8 @@ service FunctionService { // 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. - rpc CreateFunction(CreateFunctionRequest) returns (google.longrunning.Operation) { + rpc CreateFunction(CreateFunctionRequest) + returns (google.longrunning.Operation) { option (google.api.http) = { post: "/v2/{parent=projects/*/locations/*}/functions" body: "function" @@ -109,7 +112,8 @@ service FunctionService { } // Updates existing function. - rpc UpdateFunction(UpdateFunctionRequest) returns (google.longrunning.Operation) { + rpc UpdateFunction(UpdateFunctionRequest) + returns (google.longrunning.Operation) { option (google.api.http) = { patch: "/v2/{function.name=projects/*/locations/*/functions/*}" body: "function" @@ -124,7 +128,8 @@ service FunctionService { // 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. - rpc DeleteFunction(DeleteFunctionRequest) returns (google.longrunning.Operation) { + rpc DeleteFunction(DeleteFunctionRequest) + returns (google.longrunning.Operation) { option (google.api.http) = { delete: "/v2/{name=projects/*/locations/*/functions/*}" }; @@ -158,7 +163,8 @@ service FunctionService { // And this header SHOULD NOT be specified: // // * `Authorization: Bearer YOUR_TOKEN` - rpc GenerateUploadUrl(GenerateUploadUrlRequest) returns (GenerateUploadUrlResponse) { + rpc GenerateUploadUrl(GenerateUploadUrlRequest) + returns (GenerateUploadUrlResponse) { option (google.api.http) = { post: "/v2/{parent=projects/*/locations/*}/functions:generateUploadUrl" body: "*" @@ -170,7 +176,8 @@ service FunctionService { // 30 minutes of generation. // For more information about the signed URL usage see: // https://cloud.google.com/storage/docs/access-control/signed-urls - rpc GenerateDownloadUrl(GenerateDownloadUrlRequest) returns (GenerateDownloadUrlResponse) { + rpc GenerateDownloadUrl(GenerateDownloadUrlRequest) + returns (GenerateDownloadUrlResponse) { option (google.api.http) = { post: "/v2/{name=projects/*/locations/*/functions/*}:generateDownloadUrl" body: "*" @@ -234,7 +241,7 @@ message Function { // globally and match pattern `projects/*/locations/*/functions/*` string name = 1; - // Describe whether the function is gen1 or gen2. + // Describe whether the function is 1st Gen or 2nd Gen. Environment environment = 10; // User-provided description of a function. @@ -256,13 +263,27 @@ message Function { State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; // Output only. The last update timestamp of a Cloud Function. - google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + google.protobuf.Timestamp update_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; // Labels associated with this Cloud Function. map labels = 8; // Output only. State Messages for this Cloud Function. - repeated StateMessage state_messages = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + repeated StateMessage state_messages = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Resource name of a KMS crypto key (managed by the user) used to + // encrypt/decrypt function resources. + // + // It must match the pattern + // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. + string kms_key_name = 25 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; + + // Output only. The deployed url for the function. + string url = 14 [(google.api.field_behavior) = OUTPUT_ONLY]; } // Informational messages about the state of the Cloud Function or Operation. @@ -379,8 +400,25 @@ message SourceProvenance { // Describes the Build step of the function that builds a container from the // given source. message BuildConfig { - // Output only. The Cloud Build name of the latest successful deployment of the - // function. + // Docker Registry to use for storing function Docker images. + enum DockerRegistry { + // Unspecified. + DOCKER_REGISTRY_UNSPECIFIED = 0; + + // Docker images will be stored in multi-regional Container Registry + // repositories named `gcf`. + CONTAINER_REGISTRY = 1; + + // Docker images will be stored in regional Artifact Registry repositories. + // By default, GCF will create and use repositories named `gcf-artifacts` + // in every region in which a function is deployed. But the repository to + // use can also be specified by the user using the `docker_repository` + // field. + ARTIFACT_REGISTRY = 2; + } + + // Output only. The Cloud Build name of the latest successful deployment of + // the function. string build = 1 [ (google.api.field_behavior) = OUTPUT_ONLY, (google.api.resource_reference) = { @@ -407,7 +445,8 @@ message BuildConfig { Source source = 4; // Output only. A permanent fixed identifier for source. - SourceProvenance source_provenance = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + SourceProvenance source_provenance = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; // Name of the Cloud Build Custom Worker Pool that should be used to build the // function. The format of this field is @@ -422,13 +461,23 @@ message BuildConfig { // granted the role Cloud Build Custom Workers Builder // (roles/cloudbuild.customworkers.builder) in the project. string worker_pool = 5 [(google.api.resource_reference) = { - type: "cloudbuild.googleapis.com/WorkerPool" - }]; + type: "cloudbuild.googleapis.com/WorkerPool" + }]; // User-provided build-time environment variables for the function map environment_variables = 6; - // Optional. User managed repository created in Artifact Registry optionally with a + // Optional. Docker Registry to use for this deployment. This configuration is + // only applicable to 1st Gen functions, 2nd Gen functions can only use + // Artifact Registry. + // + // If `docker_repository` field is specified, this field will be automatically + // set as `ARTIFACT_REGISTRY`. + // If unspecified, it currently defaults to `CONTAINER_REGISTRY`. + // This field may be overridden by the backend for eligible deployments. + DockerRegistry docker_registry = 10 [(google.api.field_behavior) = OPTIONAL]; + + // User managed repository created in Artifact Registry optionally with a // customer managed encryption key. This is the repository to which the // function docker image will be pushed after it is built by Cloud Build. // If unspecified, GCF will create and use a repository named 'gcf-artifacts' @@ -440,16 +489,14 @@ message BuildConfig { // Cross-project repositories are not supported. // Cross-location repositories are not supported. // Repository format must be 'DOCKER'. - string docker_repository = 7 [ - (google.api.field_behavior) = OPTIONAL, - (google.api.resource_reference) = { - type: "artifactregistry.googleapis.com/Repository" - } - ]; + string docker_repository = 7 [(google.api.resource_reference) = { + type: "artifactregistry.googleapis.com/Repository" + }]; } // Describes the Service being deployed. // Currently Supported : Cloud Run (fully managed). +// Next tag: 23 message ServiceConfig { // Available egress settings. // @@ -486,14 +533,33 @@ message ServiceConfig { ALLOW_INTERNAL_AND_GCLB = 3; } + // Available security level settings. + // + // This enforces security protocol on function URL. + // + // Security level is only ocnfigurable for 1st Gen functions, If unspecified, + // SECURE_OPTIONAL will be used. 2nd Gen functions are SECURE_ALWAYS ONLY. + enum SecurityLevel { + // Unspecified. + SECURITY_LEVEL_UNSPECIFIED = 0; + + // Requests for a URL that match this handler that do not use HTTPS are + // automatically redirected to the HTTPS URL with the same path. Query + // parameters are reserved for the redirect. + SECURE_ALWAYS = 1; + + // Both HTTP and HTTPS requests with URLs that match the handler succeed + // without redirects. The application can examine the request to determine + // which protocol was used and respond accordingly. + SECURE_OPTIONAL = 2; + } + // Output only. Name of the service associated with a Function. // The format of this field is // `projects/{project}/locations/{region}/services/{service}` string service = 1 [ (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "run.googleapis.com/Service" - } + (google.api.resource_reference) = { type: "run.googleapis.com/Service" } ]; // The function execution timeout. Execution is considered failed and @@ -509,6 +575,13 @@ message ServiceConfig { // a full description. string available_memory = 13; + // The number of CPUs used in a single container instance. + // Default value is calculated from available memory. + // Supports the same values as Cloud Run, see + // https://cloud.google.com/run/docs/reference/rest/v1/Container#resourcerequirements + // Example: "1" indicates 1 vCPU + string available_cpu = 22; + // Environment variables that shall be available during function execution. map environment_variables = 4; @@ -540,8 +613,8 @@ message ServiceConfig { // The Serverless VPC Access connector that this cloud function can connect // to. The format of this field is `projects/*/locations/*/connectors/*`. string vpc_connector = 6 [(google.api.resource_reference) = { - type: "vpcaccess.googleapis.com/Connector" - }]; + type: "vpcaccess.googleapis.com/Connector" + }]; // The egress settings for the connector, controlling what traffic is diverted // through it. @@ -573,6 +646,16 @@ message ServiceConfig { // Output only. The name of service revision. string revision = 18 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Sets the maximum number of concurrent requests that each instance can + // receive. Defaults to 1. + int32 max_instance_request_concurrency = 20; + + // Security level configure whether the function only accepts https. + // This configuration is only applicable to 1st Gen functions with Http + // trigger. By default https is optional for 1st Gen functions; 2nd Gen + // functions are https ONLY. + SecurityLevel security_level = 21; } // Configuration for a secret environment variable. It has the information @@ -653,8 +736,8 @@ message EventTrigger { RETRY_POLICY_RETRY = 2; } - // Output only. The resource name of the Eventarc trigger. The format of this field is - // `projects/{project}/locations/{region}/triggers/{trigger}`. + // Output only. The resource name of the Eventarc trigger. The format of this + // field is `projects/{project}/locations/{region}/triggers/{trigger}`. string trigger = 1 [ (google.api.field_behavior) = OUTPUT_ONLY, (google.api.resource_reference) = { @@ -685,19 +768,18 @@ message EventTrigger { // will not be deleted at function deletion. string pubsub_topic = 5 [ (google.api.field_behavior) = OPTIONAL, - (google.api.resource_reference) = { - type: "pubsub.googleapis.com/Topic" - } + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } ]; - // Optional. The email of the trigger's service account. The service account must have - // permission to invoke Cloud Run services, the permission is + // Optional. The email of the trigger's service account. The service account + // must have permission to invoke Cloud Run services, the permission is // `run.routes.invoke`. // If empty, defaults to the Compute Engine default service account: // `{project_number}-compute@developer.gserviceaccount.com`. string service_account_email = 6 [(google.api.field_behavior) = OPTIONAL]; - // Optional. If unset, then defaults to ignoring failures (i.e. not retrying them). + // Optional. If unset, then defaults to ignoring failures (i.e. not retrying + // them). RetryPolicy retry_policy = 7 [(google.api.field_behavior) = OPTIONAL]; // Optional. The name of the channel associated with the trigger in @@ -739,12 +821,12 @@ message GetFunctionRequest { // Request for the `ListFunctions` method. message ListFunctionsRequest { - // Required. 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. + // Required. 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. string parent = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference) = { @@ -752,7 +834,10 @@ message ListFunctionsRequest { } ]; - // Maximum number of functions to return per call. + // Maximum number of functions to return per call. The largest allowed + // page_size is 1,000, if the page_size is omitted or specified as greater + // than 1,000 then it will be replaced as 1,000. The size of the list + // response can be less than specified when used with filters. int32 page_size = 2; // The value returned by the last @@ -787,8 +872,8 @@ message ListFunctionsResponse { // Request for the `CreateFunction` method. message CreateFunctionRequest { - // Required. The project and location in which the function should be created, specified - // in the format `projects/*/locations/*` + // Required. The project and location in which the function should be created, + // specified in the format `projects/*/locations/*` string parent = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference) = { @@ -831,14 +916,33 @@ message DeleteFunctionRequest { // Request of `GenerateSourceUploadUrl` method. message GenerateUploadUrlRequest { - // Required. The project and location in which the Google Cloud Storage signed URL - // should be generated, specified in the format `projects/*/locations/*`. + // Required. The project and location in which the Google Cloud Storage signed + // URL should be generated, specified in the format `projects/*/locations/*`. string parent = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference) = { type: "locations.googleapis.com/Location" } ]; + + // 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). + string kms_key_name = 2 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; } // Response of `GenerateSourceUploadUrl` method. @@ -861,8 +965,8 @@ message GenerateUploadUrlResponse { // Request of `GenerateDownloadUrl` method. message GenerateDownloadUrlRequest { - // Required. The name of function for which source code Google Cloud Storage signed - // URL should be generated. + // Required. The name of function for which source code Google Cloud Storage + // signed URL should be generated. string name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference) = { @@ -880,8 +984,8 @@ message GenerateDownloadUrlResponse { // Request for the `ListRuntimes` method. message ListRuntimesRequest { - // Required. The project and location from which the runtimes should be listed, - // specified in the format `projects/*/locations/*` + // Required. The project and location from which the runtimes should be + // listed, specified in the format `projects/*/locations/*` string parent = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference) = { @@ -962,8 +1066,9 @@ message OperationMetadata { // Identifies whether the user has requested cancellation // of the operation. Operations that have successfully been cancelled - // have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, - // corresponding to `Code.CANCELLED`. + // have [Operation.error][] value with a + // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + // `Code.CANCELLED`. bool cancel_requested = 6; // API version used to start the operation. diff --git a/packages/google-cloud-functions/protos/protos.d.ts b/packages/google-cloud-functions/protos/protos.d.ts index bdc14ad4750..dc6a0c168ca 100644 --- a/packages/google-cloud-functions/protos/protos.d.ts +++ b/packages/google-cloud-functions/protos/protos.d.ts @@ -3084,6 +3084,12 @@ export namespace google { /** Function stateMessages */ stateMessages?: (google.cloud.functions.v2.IStateMessage[]|null); + + /** Function kmsKeyName */ + kmsKeyName?: (string|null); + + /** Function url */ + url?: (string|null); } /** Represents a Function. */ @@ -3125,6 +3131,12 @@ export namespace google { /** Function stateMessages. */ public stateMessages: google.cloud.functions.v2.IStateMessage[]; + /** Function kmsKeyName. */ + public kmsKeyName: string; + + /** Function url. */ + public url: string; + /** * Creates a new Function instance using the specified properties. * @param [properties] Properties to set @@ -3814,6 +3826,9 @@ export namespace google { /** BuildConfig environmentVariables */ environmentVariables?: ({ [k: string]: string }|null); + /** BuildConfig dockerRegistry */ + dockerRegistry?: (google.cloud.functions.v2.BuildConfig.DockerRegistry|keyof typeof google.cloud.functions.v2.BuildConfig.DockerRegistry|null); + /** BuildConfig dockerRepository */ dockerRepository?: (string|null); } @@ -3848,6 +3863,9 @@ export namespace google { /** BuildConfig environmentVariables. */ public environmentVariables: { [k: string]: string }; + /** BuildConfig dockerRegistry. */ + public dockerRegistry: (google.cloud.functions.v2.BuildConfig.DockerRegistry|keyof typeof google.cloud.functions.v2.BuildConfig.DockerRegistry); + /** BuildConfig dockerRepository. */ public dockerRepository: string; @@ -3929,6 +3947,16 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace BuildConfig { + + /** DockerRegistry enum. */ + enum DockerRegistry { + DOCKER_REGISTRY_UNSPECIFIED = 0, + CONTAINER_REGISTRY = 1, + ARTIFACT_REGISTRY = 2 + } + } + /** Properties of a ServiceConfig. */ interface IServiceConfig { @@ -3941,6 +3969,9 @@ export namespace google { /** ServiceConfig availableMemory */ availableMemory?: (string|null); + /** ServiceConfig availableCpu */ + availableCpu?: (string|null); + /** ServiceConfig environmentVariables */ environmentVariables?: ({ [k: string]: string }|null); @@ -3976,6 +4007,12 @@ export namespace google { /** ServiceConfig revision */ revision?: (string|null); + + /** ServiceConfig maxInstanceRequestConcurrency */ + maxInstanceRequestConcurrency?: (number|null); + + /** ServiceConfig securityLevel */ + securityLevel?: (google.cloud.functions.v2.ServiceConfig.SecurityLevel|keyof typeof google.cloud.functions.v2.ServiceConfig.SecurityLevel|null); } /** Represents a ServiceConfig. */ @@ -3996,6 +4033,9 @@ export namespace google { /** ServiceConfig availableMemory. */ public availableMemory: string; + /** ServiceConfig availableCpu. */ + public availableCpu: string; + /** ServiceConfig environmentVariables. */ public environmentVariables: { [k: string]: string }; @@ -4032,6 +4072,12 @@ export namespace google { /** ServiceConfig revision. */ public revision: string; + /** ServiceConfig maxInstanceRequestConcurrency. */ + public maxInstanceRequestConcurrency: number; + + /** ServiceConfig securityLevel. */ + public securityLevel: (google.cloud.functions.v2.ServiceConfig.SecurityLevel|keyof typeof google.cloud.functions.v2.ServiceConfig.SecurityLevel); + /** * Creates a new ServiceConfig instance using the specified properties. * @param [properties] Properties to set @@ -4126,6 +4172,13 @@ export namespace google { ALLOW_INTERNAL_ONLY = 2, ALLOW_INTERNAL_AND_GCLB = 3 } + + /** SecurityLevel enum. */ + enum SecurityLevel { + SECURITY_LEVEL_UNSPECIFIED = 0, + SECURE_ALWAYS = 1, + SECURE_OPTIONAL = 2 + } } /** Properties of a SecretEnvVar. */ @@ -5363,6 +5416,9 @@ export namespace google { /** GenerateUploadUrlRequest parent */ parent?: (string|null); + + /** GenerateUploadUrlRequest kmsKeyName */ + kmsKeyName?: (string|null); } /** Represents a GenerateUploadUrlRequest. */ @@ -5377,6 +5433,9 @@ export namespace google { /** GenerateUploadUrlRequest parent. */ public parent: string; + /** GenerateUploadUrlRequest kmsKeyName. */ + public kmsKeyName: string; + /** * Creates a new GenerateUploadUrlRequest instance using the specified properties. * @param [properties] Properties to set diff --git a/packages/google-cloud-functions/protos/protos.js b/packages/google-cloud-functions/protos/protos.js index 08d582ef736..49abe9fc5ba 100644 --- a/packages/google-cloud-functions/protos/protos.js +++ b/packages/google-cloud-functions/protos/protos.js @@ -7347,6 +7347,8 @@ * @property {google.protobuf.ITimestamp|null} [updateTime] Function updateTime * @property {Object.|null} [labels] Function labels * @property {Array.|null} [stateMessages] Function stateMessages + * @property {string|null} [kmsKeyName] Function kmsKeyName + * @property {string|null} [url] Function url */ /** @@ -7446,6 +7448,22 @@ */ Function.prototype.stateMessages = $util.emptyArray; + /** + * Function kmsKeyName. + * @member {string} kmsKeyName + * @memberof google.cloud.functions.v2.Function + * @instance + */ + Function.prototype.kmsKeyName = ""; + + /** + * Function url. + * @member {string} url + * @memberof google.cloud.functions.v2.Function + * @instance + */ + Function.prototype.url = ""; + /** * Creates a new Function instance using the specified properties. * @function create @@ -7492,6 +7510,10 @@ $root.google.cloud.functions.v2.StateMessage.encode(message.stateMessages[i], writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); if (message.environment != null && Object.hasOwnProperty.call(message, "environment")) writer.uint32(/* id 10, wireType 0 =*/80).int32(message.environment); + if (message.url != null && Object.hasOwnProperty.call(message, "url")) + writer.uint32(/* id 14, wireType 2 =*/114).string(message.url); + if (message.kmsKeyName != null && Object.hasOwnProperty.call(message, "kmsKeyName")) + writer.uint32(/* id 25, wireType 2 =*/202).string(message.kmsKeyName); return writer; }; @@ -7587,6 +7609,14 @@ message.stateMessages.push($root.google.cloud.functions.v2.StateMessage.decode(reader, reader.uint32())); break; } + case 25: { + message.kmsKeyName = reader.string(); + break; + } + case 14: { + message.url = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -7686,6 +7716,12 @@ return "stateMessages." + error; } } + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + if (!$util.isString(message.kmsKeyName)) + return "kmsKeyName: string expected"; + if (message.url != null && message.hasOwnProperty("url")) + if (!$util.isString(message.url)) + return "url: string expected"; return null; }; @@ -7794,6 +7830,10 @@ message.stateMessages[i] = $root.google.cloud.functions.v2.StateMessage.fromObject(object.stateMessages[i]); } } + if (object.kmsKeyName != null) + message.kmsKeyName = String(object.kmsKeyName); + if (object.url != null) + message.url = String(object.url); return message; }; @@ -7823,6 +7863,8 @@ object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; object.updateTime = null; object.environment = options.enums === String ? "ENVIRONMENT_UNSPECIFIED" : 0; + object.url = ""; + object.kmsKeyName = ""; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -7851,6 +7893,10 @@ } if (message.environment != null && message.hasOwnProperty("environment")) object.environment = options.enums === String ? $root.google.cloud.functions.v2.Environment[message.environment] === undefined ? message.environment : $root.google.cloud.functions.v2.Environment[message.environment] : message.environment; + if (message.url != null && message.hasOwnProperty("url")) + object.url = message.url; + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + object.kmsKeyName = message.kmsKeyName; return object; }; @@ -9351,6 +9397,7 @@ * @property {google.cloud.functions.v2.ISourceProvenance|null} [sourceProvenance] BuildConfig sourceProvenance * @property {string|null} [workerPool] BuildConfig workerPool * @property {Object.|null} [environmentVariables] BuildConfig environmentVariables + * @property {google.cloud.functions.v2.BuildConfig.DockerRegistry|null} [dockerRegistry] BuildConfig dockerRegistry * @property {string|null} [dockerRepository] BuildConfig dockerRepository */ @@ -9426,6 +9473,14 @@ */ BuildConfig.prototype.environmentVariables = $util.emptyObject; + /** + * BuildConfig dockerRegistry. + * @member {google.cloud.functions.v2.BuildConfig.DockerRegistry} dockerRegistry + * @memberof google.cloud.functions.v2.BuildConfig + * @instance + */ + BuildConfig.prototype.dockerRegistry = 0; + /** * BuildConfig dockerRepository. * @member {string} dockerRepository @@ -9475,6 +9530,8 @@ writer.uint32(/* id 7, wireType 2 =*/58).string(message.dockerRepository); if (message.sourceProvenance != null && Object.hasOwnProperty.call(message, "sourceProvenance")) $root.google.cloud.functions.v2.SourceProvenance.encode(message.sourceProvenance, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.dockerRegistry != null && Object.hasOwnProperty.call(message, "dockerRegistry")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.dockerRegistry); return writer; }; @@ -9556,6 +9613,10 @@ message.environmentVariables[key] = value; break; } + case 10: { + message.dockerRegistry = reader.int32(); + break; + } case 7: { message.dockerRepository = reader.string(); break; @@ -9625,6 +9686,15 @@ if (!$util.isString(message.environmentVariables[key[i]])) return "environmentVariables: string{k:string} expected"; } + if (message.dockerRegistry != null && message.hasOwnProperty("dockerRegistry")) + switch (message.dockerRegistry) { + default: + return "dockerRegistry: enum value expected"; + case 0: + case 1: + case 2: + break; + } if (message.dockerRepository != null && message.hasOwnProperty("dockerRepository")) if (!$util.isString(message.dockerRepository)) return "dockerRepository: string expected"; @@ -9668,6 +9738,26 @@ for (var keys = Object.keys(object.environmentVariables), i = 0; i < keys.length; ++i) message.environmentVariables[keys[i]] = String(object.environmentVariables[keys[i]]); } + switch (object.dockerRegistry) { + default: + if (typeof object.dockerRegistry === "number") { + message.dockerRegistry = object.dockerRegistry; + break; + } + break; + case "DOCKER_REGISTRY_UNSPECIFIED": + case 0: + message.dockerRegistry = 0; + break; + case "CONTAINER_REGISTRY": + case 1: + message.dockerRegistry = 1; + break; + case "ARTIFACT_REGISTRY": + case 2: + message.dockerRegistry = 2; + break; + } if (object.dockerRepository != null) message.dockerRepository = String(object.dockerRepository); return message; @@ -9696,6 +9786,7 @@ object.workerPool = ""; object.dockerRepository = ""; object.sourceProvenance = null; + object.dockerRegistry = options.enums === String ? "DOCKER_REGISTRY_UNSPECIFIED" : 0; } if (message.build != null && message.hasOwnProperty("build")) object.build = message.build; @@ -9717,6 +9808,8 @@ object.dockerRepository = message.dockerRepository; if (message.sourceProvenance != null && message.hasOwnProperty("sourceProvenance")) object.sourceProvenance = $root.google.cloud.functions.v2.SourceProvenance.toObject(message.sourceProvenance, options); + if (message.dockerRegistry != null && message.hasOwnProperty("dockerRegistry")) + object.dockerRegistry = options.enums === String ? $root.google.cloud.functions.v2.BuildConfig.DockerRegistry[message.dockerRegistry] === undefined ? message.dockerRegistry : $root.google.cloud.functions.v2.BuildConfig.DockerRegistry[message.dockerRegistry] : message.dockerRegistry; return object; }; @@ -9746,6 +9839,22 @@ return typeUrlPrefix + "/google.cloud.functions.v2.BuildConfig"; }; + /** + * DockerRegistry enum. + * @name google.cloud.functions.v2.BuildConfig.DockerRegistry + * @enum {number} + * @property {number} DOCKER_REGISTRY_UNSPECIFIED=0 DOCKER_REGISTRY_UNSPECIFIED value + * @property {number} CONTAINER_REGISTRY=1 CONTAINER_REGISTRY value + * @property {number} ARTIFACT_REGISTRY=2 ARTIFACT_REGISTRY value + */ + BuildConfig.DockerRegistry = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DOCKER_REGISTRY_UNSPECIFIED"] = 0; + values[valuesById[1] = "CONTAINER_REGISTRY"] = 1; + values[valuesById[2] = "ARTIFACT_REGISTRY"] = 2; + return values; + })(); + return BuildConfig; })(); @@ -9758,6 +9867,7 @@ * @property {string|null} [service] ServiceConfig service * @property {number|null} [timeoutSeconds] ServiceConfig timeoutSeconds * @property {string|null} [availableMemory] ServiceConfig availableMemory + * @property {string|null} [availableCpu] ServiceConfig availableCpu * @property {Object.|null} [environmentVariables] ServiceConfig environmentVariables * @property {number|null} [maxInstanceCount] ServiceConfig maxInstanceCount * @property {number|null} [minInstanceCount] ServiceConfig minInstanceCount @@ -9770,6 +9880,8 @@ * @property {Array.|null} [secretEnvironmentVariables] ServiceConfig secretEnvironmentVariables * @property {Array.|null} [secretVolumes] ServiceConfig secretVolumes * @property {string|null} [revision] ServiceConfig revision + * @property {number|null} [maxInstanceRequestConcurrency] ServiceConfig maxInstanceRequestConcurrency + * @property {google.cloud.functions.v2.ServiceConfig.SecurityLevel|null} [securityLevel] ServiceConfig securityLevel */ /** @@ -9814,6 +9926,14 @@ */ ServiceConfig.prototype.availableMemory = ""; + /** + * ServiceConfig availableCpu. + * @member {string} availableCpu + * @memberof google.cloud.functions.v2.ServiceConfig + * @instance + */ + ServiceConfig.prototype.availableCpu = ""; + /** * ServiceConfig environmentVariables. * @member {Object.} environmentVariables @@ -9910,6 +10030,22 @@ */ ServiceConfig.prototype.revision = ""; + /** + * ServiceConfig maxInstanceRequestConcurrency. + * @member {number} maxInstanceRequestConcurrency + * @memberof google.cloud.functions.v2.ServiceConfig + * @instance + */ + ServiceConfig.prototype.maxInstanceRequestConcurrency = 0; + + /** + * ServiceConfig securityLevel. + * @member {google.cloud.functions.v2.ServiceConfig.SecurityLevel} securityLevel + * @memberof google.cloud.functions.v2.ServiceConfig + * @instance + */ + ServiceConfig.prototype.securityLevel = 0; + /** * Creates a new ServiceConfig instance using the specified properties. * @function create @@ -9967,6 +10103,12 @@ if (message.secretVolumes != null && message.secretVolumes.length) for (var i = 0; i < message.secretVolumes.length; ++i) $root.google.cloud.functions.v2.SecretVolume.encode(message.secretVolumes[i], writer.uint32(/* id 19, wireType 2 =*/154).fork()).ldelim(); + if (message.maxInstanceRequestConcurrency != null && Object.hasOwnProperty.call(message, "maxInstanceRequestConcurrency")) + writer.uint32(/* id 20, wireType 0 =*/160).int32(message.maxInstanceRequestConcurrency); + if (message.securityLevel != null && Object.hasOwnProperty.call(message, "securityLevel")) + writer.uint32(/* id 21, wireType 0 =*/168).int32(message.securityLevel); + if (message.availableCpu != null && Object.hasOwnProperty.call(message, "availableCpu")) + writer.uint32(/* id 22, wireType 2 =*/178).string(message.availableCpu); return writer; }; @@ -10013,6 +10155,10 @@ message.availableMemory = reader.string(); break; } + case 22: { + message.availableCpu = reader.string(); + break; + } case 4: { if (message.environmentVariables === $util.emptyObject) message.environmentVariables = {}; @@ -10084,6 +10230,14 @@ message.revision = reader.string(); break; } + case 20: { + message.maxInstanceRequestConcurrency = reader.int32(); + break; + } + case 21: { + message.securityLevel = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -10128,6 +10282,9 @@ if (message.availableMemory != null && message.hasOwnProperty("availableMemory")) if (!$util.isString(message.availableMemory)) return "availableMemory: string expected"; + if (message.availableCpu != null && message.hasOwnProperty("availableCpu")) + if (!$util.isString(message.availableCpu)) + return "availableCpu: string expected"; if (message.environmentVariables != null && message.hasOwnProperty("environmentVariables")) { if (!$util.isObject(message.environmentVariables)) return "environmentVariables: object expected"; @@ -10194,6 +10351,18 @@ if (message.revision != null && message.hasOwnProperty("revision")) if (!$util.isString(message.revision)) return "revision: string expected"; + if (message.maxInstanceRequestConcurrency != null && message.hasOwnProperty("maxInstanceRequestConcurrency")) + if (!$util.isInteger(message.maxInstanceRequestConcurrency)) + return "maxInstanceRequestConcurrency: integer expected"; + if (message.securityLevel != null && message.hasOwnProperty("securityLevel")) + switch (message.securityLevel) { + default: + return "securityLevel: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -10215,6 +10384,8 @@ message.timeoutSeconds = object.timeoutSeconds | 0; if (object.availableMemory != null) message.availableMemory = String(object.availableMemory); + if (object.availableCpu != null) + message.availableCpu = String(object.availableCpu); if (object.environmentVariables) { if (typeof object.environmentVariables !== "object") throw TypeError(".google.cloud.functions.v2.ServiceConfig.environmentVariables: object expected"); @@ -10300,6 +10471,28 @@ } if (object.revision != null) message.revision = String(object.revision); + if (object.maxInstanceRequestConcurrency != null) + message.maxInstanceRequestConcurrency = object.maxInstanceRequestConcurrency | 0; + switch (object.securityLevel) { + default: + if (typeof object.securityLevel === "number") { + message.securityLevel = object.securityLevel; + break; + } + break; + case "SECURITY_LEVEL_UNSPECIFIED": + case 0: + message.securityLevel = 0; + break; + case "SECURE_ALWAYS": + case 1: + message.securityLevel = 1; + break; + case "SECURE_OPTIONAL": + case 2: + message.securityLevel = 2; + break; + } return message; }; @@ -10335,6 +10528,9 @@ object.availableMemory = ""; object.allTrafficOnLatestRevision = false; object.revision = ""; + object.maxInstanceRequestConcurrency = 0; + object.securityLevel = options.enums === String ? "SECURITY_LEVEL_UNSPECIFIED" : 0; + object.availableCpu = ""; } if (message.service != null && message.hasOwnProperty("service")) object.service = message.service; @@ -10376,6 +10572,12 @@ for (var j = 0; j < message.secretVolumes.length; ++j) object.secretVolumes[j] = $root.google.cloud.functions.v2.SecretVolume.toObject(message.secretVolumes[j], options); } + if (message.maxInstanceRequestConcurrency != null && message.hasOwnProperty("maxInstanceRequestConcurrency")) + object.maxInstanceRequestConcurrency = message.maxInstanceRequestConcurrency; + if (message.securityLevel != null && message.hasOwnProperty("securityLevel")) + object.securityLevel = options.enums === String ? $root.google.cloud.functions.v2.ServiceConfig.SecurityLevel[message.securityLevel] === undefined ? message.securityLevel : $root.google.cloud.functions.v2.ServiceConfig.SecurityLevel[message.securityLevel] : message.securityLevel; + if (message.availableCpu != null && message.hasOwnProperty("availableCpu")) + object.availableCpu = message.availableCpu; return object; }; @@ -10439,6 +10641,22 @@ return values; })(); + /** + * SecurityLevel enum. + * @name google.cloud.functions.v2.ServiceConfig.SecurityLevel + * @enum {number} + * @property {number} SECURITY_LEVEL_UNSPECIFIED=0 SECURITY_LEVEL_UNSPECIFIED value + * @property {number} SECURE_ALWAYS=1 SECURE_ALWAYS value + * @property {number} SECURE_OPTIONAL=2 SECURE_OPTIONAL value + */ + ServiceConfig.SecurityLevel = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SECURITY_LEVEL_UNSPECIFIED"] = 0; + values[valuesById[1] = "SECURE_ALWAYS"] = 1; + values[valuesById[2] = "SECURE_OPTIONAL"] = 2; + return values; + })(); + return ServiceConfig; })(); @@ -13403,6 +13621,7 @@ * @memberof google.cloud.functions.v2 * @interface IGenerateUploadUrlRequest * @property {string|null} [parent] GenerateUploadUrlRequest parent + * @property {string|null} [kmsKeyName] GenerateUploadUrlRequest kmsKeyName */ /** @@ -13428,6 +13647,14 @@ */ GenerateUploadUrlRequest.prototype.parent = ""; + /** + * GenerateUploadUrlRequest kmsKeyName. + * @member {string} kmsKeyName + * @memberof google.cloud.functions.v2.GenerateUploadUrlRequest + * @instance + */ + GenerateUploadUrlRequest.prototype.kmsKeyName = ""; + /** * Creates a new GenerateUploadUrlRequest instance using the specified properties. * @function create @@ -13454,6 +13681,8 @@ writer = $Writer.create(); if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.kmsKeyName != null && Object.hasOwnProperty.call(message, "kmsKeyName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.kmsKeyName); return writer; }; @@ -13492,6 +13721,10 @@ message.parent = reader.string(); break; } + case 2: { + message.kmsKeyName = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -13530,6 +13763,9 @@ if (message.parent != null && message.hasOwnProperty("parent")) if (!$util.isString(message.parent)) return "parent: string expected"; + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + if (!$util.isString(message.kmsKeyName)) + return "kmsKeyName: string expected"; return null; }; @@ -13547,6 +13783,8 @@ var message = new $root.google.cloud.functions.v2.GenerateUploadUrlRequest(); if (object.parent != null) message.parent = String(object.parent); + if (object.kmsKeyName != null) + message.kmsKeyName = String(object.kmsKeyName); return message; }; @@ -13563,10 +13801,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.parent = ""; + object.kmsKeyName = ""; + } if (message.parent != null && message.hasOwnProperty("parent")) object.parent = message.parent; + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + object.kmsKeyName = message.kmsKeyName; return object; }; diff --git a/packages/google-cloud-functions/protos/protos.json b/packages/google-cloud-functions/protos/protos.json index c3b9f8605e6..b4479d70e73 100644 --- a/packages/google-cloud-functions/protos/protos.json +++ b/packages/google-cloud-functions/protos/protos.json @@ -1060,6 +1060,20 @@ "options": { "(google.api.field_behavior)": "OUTPUT_ONLY" } + }, + "kmsKeyName": { + "type": "string", + "id": 25, + "options": { + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey" + } + }, + "url": { + "type": "string", + "id": 14, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } } }, "nested": { @@ -1231,14 +1245,29 @@ "type": "string", "id": 6 }, + "dockerRegistry": { + "type": "DockerRegistry", + "id": 10, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, "dockerRepository": { "type": "string", "id": 7, "options": { - "(google.api.field_behavior)": "OPTIONAL", "(google.api.resource_reference).type": "artifactregistry.googleapis.com/Repository" } } + }, + "nested": { + "DockerRegistry": { + "values": { + "DOCKER_REGISTRY_UNSPECIFIED": 0, + "CONTAINER_REGISTRY": 1, + "ARTIFACT_REGISTRY": 2 + } + } } }, "ServiceConfig": { @@ -1259,6 +1288,10 @@ "type": "string", "id": 13 }, + "availableCpu": { + "type": "string", + "id": 22 + }, "environmentVariables": { "keyType": "string", "type": "string", @@ -1318,6 +1351,14 @@ "options": { "(google.api.field_behavior)": "OUTPUT_ONLY" } + }, + "maxInstanceRequestConcurrency": { + "type": "int32", + "id": 20 + }, + "securityLevel": { + "type": "SecurityLevel", + "id": 21 } }, "nested": { @@ -1335,6 +1376,13 @@ "ALLOW_INTERNAL_ONLY": 2, "ALLOW_INTERNAL_AND_GCLB": 3 } + }, + "SecurityLevel": { + "values": { + "SECURITY_LEVEL_UNSPECIFIED": 0, + "SECURE_ALWAYS": 1, + "SECURE_OPTIONAL": 2 + } } } }, @@ -1602,6 +1650,13 @@ "(google.api.field_behavior)": "REQUIRED", "(google.api.resource_reference).type": "locations.googleapis.com/Location" } + }, + "kmsKeyName": { + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey" + } } } }, diff --git a/packages/google-cloud-functions/samples/generated/v1/snippet_metadata.google.cloud.functions.v1.json b/packages/google-cloud-functions/samples/generated/v1/snippet_metadata.google.cloud.functions.v1.json index 0661e90eaae..887b9c1a7f8 100644 --- a/packages/google-cloud-functions/samples/generated/v1/snippet_metadata.google.cloud.functions.v1.json +++ b/packages/google-cloud-functions/samples/generated/v1/snippet_metadata.google.cloud.functions.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-functions", - "version": "2.3.0", + "version": "2.3.1", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-functions/samples/generated/v2/function_service.create_function.js b/packages/google-cloud-functions/samples/generated/v2/function_service.create_function.js index bac9fadb7a4..08fde6038e3 100644 --- a/packages/google-cloud-functions/samples/generated/v2/function_service.create_function.js +++ b/packages/google-cloud-functions/samples/generated/v2/function_service.create_function.js @@ -29,8 +29,8 @@ function main(parent, function1) { * 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/*` + * Required. The project and location in which the function should be created, + * specified in the format `projects/* /locations/*` */ // const parent = 'abc123' /** diff --git a/packages/google-cloud-functions/samples/generated/v2/function_service.generate_download_url.js b/packages/google-cloud-functions/samples/generated/v2/function_service.generate_download_url.js index 57acb621ef5..069b98c675b 100644 --- a/packages/google-cloud-functions/samples/generated/v2/function_service.generate_download_url.js +++ b/packages/google-cloud-functions/samples/generated/v2/function_service.generate_download_url.js @@ -29,8 +29,8 @@ function main(name) { * TODO(developer): Uncomment these variables before running the sample. */ /** - * Required. The name of function for which source code Google Cloud Storage signed - * URL should be generated. + * Required. The name of function for which source code Google Cloud Storage + * signed URL should be generated. */ // const name = 'abc123' diff --git a/packages/google-cloud-functions/samples/generated/v2/function_service.generate_upload_url.js b/packages/google-cloud-functions/samples/generated/v2/function_service.generate_upload_url.js index 8b786824f43..a38d4bf7647 100644 --- a/packages/google-cloud-functions/samples/generated/v2/function_service.generate_upload_url.js +++ b/packages/google-cloud-functions/samples/generated/v2/function_service.generate_upload_url.js @@ -29,10 +29,26 @@ function main(parent) { * TODO(developer): Uncomment these variables before running the sample. */ /** - * Required. The project and location in which the Google Cloud Storage signed URL - * should be generated, specified in the format `projects/* /locations/*`. + * Required. 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). + */ + // const kmsKeyName = 'abc123' // Imports the Functions library const {FunctionServiceClient} = require('@google-cloud/functions').v2; diff --git a/packages/google-cloud-functions/samples/generated/v2/function_service.list_functions.js b/packages/google-cloud-functions/samples/generated/v2/function_service.list_functions.js index 769fc5c102d..bf396080a4d 100644 --- a/packages/google-cloud-functions/samples/generated/v2/function_service.list_functions.js +++ b/packages/google-cloud-functions/samples/generated/v2/function_service.list_functions.js @@ -29,16 +29,19 @@ function main(parent) { * TODO(developer): Uncomment these variables before running the sample. */ /** - * Required. 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. + * Required. 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. + * Maximum number of functions to return per call. The largest allowed + * page_size is 1,000, if the page_size is omitted or specified as greater + * than 1,000 then it will be replaced as 1,000. The size of the list + * response can be less than specified when used with filters. */ // const pageSize = 1234 /** diff --git a/packages/google-cloud-functions/samples/generated/v2/function_service.list_runtimes.js b/packages/google-cloud-functions/samples/generated/v2/function_service.list_runtimes.js index 5cdab61a5d0..d1ee7e22ebd 100644 --- a/packages/google-cloud-functions/samples/generated/v2/function_service.list_runtimes.js +++ b/packages/google-cloud-functions/samples/generated/v2/function_service.list_runtimes.js @@ -29,8 +29,8 @@ function main(parent) { * TODO(developer): Uncomment these variables before running the sample. */ /** - * Required. The project and location from which the runtimes should be listed, - * specified in the format `projects/* /locations/*` + * Required. The project and location from which the runtimes should be + * listed, specified in the format `projects/* /locations/*` */ // const parent = 'abc123' /** diff --git a/packages/google-cloud-functions/samples/generated/v2/snippet_metadata.google.cloud.functions.v2.json b/packages/google-cloud-functions/samples/generated/v2/snippet_metadata.google.cloud.functions.v2.json index 4d0e2b9f51f..99e0908e8b7 100644 --- a/packages/google-cloud-functions/samples/generated/v2/snippet_metadata.google.cloud.functions.v2.json +++ b/packages/google-cloud-functions/samples/generated/v2/snippet_metadata.google.cloud.functions.v2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-functions", - "version": "2.3.0", + "version": "2.3.1", "language": "TYPESCRIPT", "apis": [ { @@ -62,7 +62,7 @@ "segments": [ { "start": 25, - "end": 82, + "end": 85, "type": "FULL" } ], @@ -250,7 +250,7 @@ "segments": [ { "start": 25, - "end": 54, + "end": 70, "type": "FULL" } ], @@ -262,6 +262,10 @@ { "name": "parent", "type": "TYPE_STRING" + }, + { + "name": "kms_key_name", + "type": "TYPE_STRING" } ], "resultType": ".google.cloud.functions.v2.GenerateUploadUrlResponse", diff --git a/packages/google-cloud-functions/samples/generated/v2alpha/snippet_metadata.google.cloud.functions.v2alpha.json b/packages/google-cloud-functions/samples/generated/v2alpha/snippet_metadata.google.cloud.functions.v2alpha.json index ba03137cc20..78ec467a86e 100644 --- a/packages/google-cloud-functions/samples/generated/v2alpha/snippet_metadata.google.cloud.functions.v2alpha.json +++ b/packages/google-cloud-functions/samples/generated/v2alpha/snippet_metadata.google.cloud.functions.v2alpha.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-functions", - "version": "2.3.0", + "version": "2.3.1", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-functions/samples/generated/v2beta/snippet_metadata.google.cloud.functions.v2beta.json b/packages/google-cloud-functions/samples/generated/v2beta/snippet_metadata.google.cloud.functions.v2beta.json index 9f2612c8138..bea6290d2b7 100644 --- a/packages/google-cloud-functions/samples/generated/v2beta/snippet_metadata.google.cloud.functions.v2beta.json +++ b/packages/google-cloud-functions/samples/generated/v2beta/snippet_metadata.google.cloud.functions.v2beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-functions", - "version": "2.3.0", + "version": "2.3.1", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-functions/src/v2/function_service_client.ts b/packages/google-cloud-functions/src/v2/function_service_client.ts index 06988a343c1..8146297f6e4 100644 --- a/packages/google-cloud-functions/src/v2/function_service_client.ts +++ b/packages/google-cloud-functions/src/v2/function_service_client.ts @@ -207,6 +207,9 @@ export class FunctionServiceClient { connectorPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/connectors/{connector}' ), + cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' + ), functionPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/functions/{function}' ), @@ -580,8 +583,24 @@ export class FunctionServiceClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * Required. The project and location in which the Google Cloud Storage signed URL - * should be generated, specified in the format `projects/* /locations/*`. + * Required. The project and location in which the Google Cloud Storage signed + * URL should be generated, specified in the format `projects/* /locations/*`. + * @param {string} request.kmsKeyName + * 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). * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -676,8 +695,8 @@ export class FunctionServiceClient { * @param {Object} request * The request object that will be sent. * @param {string} request.name - * Required. The name of function for which source code Google Cloud Storage signed - * URL should be generated. + * Required. The name of function for which source code Google Cloud Storage + * signed URL should be generated. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -768,8 +787,8 @@ export class FunctionServiceClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * Required. The project and location from which the runtimes should be listed, - * specified in the format `projects/* /locations/*` + * Required. The project and location from which the runtimes should be + * listed, specified in the format `projects/* /locations/*` * @param {string} request.filter * The filter for Runtimes that match the filter expression, * following the syntax outlined in https://google.aip.dev/160. @@ -860,8 +879,8 @@ export class FunctionServiceClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * Required. The project and location in which the function should be created, specified - * in the format `projects/* /locations/*` + * Required. The project and location in which the function should be created, + * specified in the format `projects/* /locations/*` * @param {google.cloud.functions.v2.Function} request.function * Required. Function to be created. * @param {string} request.functionId @@ -1289,14 +1308,17 @@ export class FunctionServiceClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * Required. 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. + * Required. 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. * @param {number} request.pageSize - * Maximum number of functions to return per call. + * Maximum number of functions to return per call. The largest allowed + * page_size is 1,000, if the page_size is omitted or specified as greater + * than 1,000 then it will be replaced as 1,000. The size of the list + * response can be less than specified when used with filters. * @param {string} request.pageToken * The value returned by the last * `ListFunctionsResponse`; indicates that @@ -1402,14 +1424,17 @@ export class FunctionServiceClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * Required. 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. + * Required. 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. * @param {number} request.pageSize - * Maximum number of functions to return per call. + * Maximum number of functions to return per call. The largest allowed + * page_size is 1,000, if the page_size is omitted or specified as greater + * than 1,000 then it will be replaced as 1,000. The size of the list + * response can be less than specified when used with filters. * @param {string} request.pageToken * The value returned by the last * `ListFunctionsResponse`; indicates that @@ -1463,14 +1488,17 @@ export class FunctionServiceClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * Required. 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. + * Required. 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. * @param {number} request.pageSize - * Maximum number of functions to return per call. + * Maximum number of functions to return per call. The largest allowed + * page_size is 1,000, if the page_size is omitted or specified as greater + * than 1,000 then it will be replaced as 1,000. The size of the list + * response can be less than specified when used with filters. * @param {string} request.pageToken * The value returned by the last * `ListFunctionsResponse`; indicates that @@ -2066,6 +2094,77 @@ export class FunctionServiceClient { .connector; } + /** + * Return a fully-qualified cryptoKey resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} key_ring + * @param {string} crypto_key + * @returns {string} Resource name string. + */ + cryptoKeyPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string + ) { + return this.pathTemplates.cryptoKeyPathTemplate.render({ + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + }); + } + + /** + * Parse the project from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .project; + } + + /** + * Parse the location from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .location; + } + + /** + * Parse the key_ring from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the key_ring. + */ + matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .key_ring; + } + + /** + * Parse the crypto_key from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the crypto_key. + */ + matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .crypto_key; + } + /** * Return a fully-qualified function resource name string. * diff --git a/packages/google-cloud-functions/test/gapic_function_service_v2.ts b/packages/google-cloud-functions/test/gapic_function_service_v2.ts index 1caf0969bd9..0ef209975eb 100644 --- a/packages/google-cloud-functions/test/gapic_function_service_v2.ts +++ b/packages/google-cloud-functions/test/gapic_function_service_v2.ts @@ -2693,6 +2693,82 @@ describe('v2.FunctionServiceClient', () => { }); }); + describe('cryptoKey', () => { + const fakePath = '/rendered/path/cryptoKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = new functionserviceModule.v2.FunctionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cryptoKeyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cryptoKeyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cryptoKeyPath', () => { + const result = client.cryptoKeyPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cryptoKeyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCryptoKeyName', () => { + const result = client.matchProjectFromCryptoKeyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCryptoKeyName', () => { + const result = client.matchLocationFromCryptoKeyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchKeyRingFromCryptoKeyName', () => { + const result = client.matchKeyRingFromCryptoKeyName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCryptoKeyFromCryptoKeyName', () => { + const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + (client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('function', () => { const fakePath = '/rendered/path/function'; const expectedParameters = {