diff --git a/packages/google-cloud-parallelstore/protos/google/cloud/parallelstore/v1beta/parallelstore.proto b/packages/google-cloud-parallelstore/protos/google/cloud/parallelstore/v1beta/parallelstore.proto index 743dd57a3f5..0114beec790 100644 --- a/packages/google-cloud-parallelstore/protos/google/cloud/parallelstore/v1beta/parallelstore.proto +++ b/packages/google-cloud-parallelstore/protos/google/cloud/parallelstore/v1beta/parallelstore.proto @@ -41,6 +41,10 @@ option (google.api.resource_definition) = { type: "compute.googleapis.com/Address" pattern: "projects/{project}/regions/{region}/addresses/{address}" }; +option (google.api.resource_definition) = { + type: "iam.googleapis.com/ServiceAccount" + pattern: "projects/{project}/serviceAccounts/{service_account}" +}; // Service describing handlers for resources // Configures and manages parallelstore resources. @@ -517,6 +521,18 @@ message ImportDataRequest { (google.api.field_info).format = UUID4, (google.api.field_behavior) = OPTIONAL ]; + + // Optional. User-specified Service Account (SA) credentials to be used when + // performing the transfer. + // Format: `projects/{project_id}/serviceAccounts/{service_account}` + // If unspecified, the Parallelstore service agent is used: + // service-@gcp-sa-parallelstore.iam.gserviceaccount.com) + string service_account = 5 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "iam.googleapis.com/ServiceAccount" + } + ]; } // Message representing the request exporting data from Cloud Storage to @@ -559,6 +575,18 @@ message ExportDataRequest { (google.api.field_info).format = UUID4, (google.api.field_behavior) = OPTIONAL ]; + + // Optional. User-specified Service Account (SA) credentials to be used when + // performing the transfer. + // Format: `projects/{project_id}/serviceAccounts/{service_account}` + // If unspecified, the Parallelstore service agent is used: + // service-@gcp-sa-parallelstore.iam.gserviceaccount.com) + string service_account = 5 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "iam.googleapis.com/ServiceAccount" + } + ]; } // ImportDataResponse is the response returned from ImportData rpc. diff --git a/packages/google-cloud-parallelstore/protos/protos.d.ts b/packages/google-cloud-parallelstore/protos/protos.d.ts index 4f62d4136d0..6ee2f9d043c 100644 --- a/packages/google-cloud-parallelstore/protos/protos.d.ts +++ b/packages/google-cloud-parallelstore/protos/protos.d.ts @@ -1568,6 +1568,9 @@ export namespace google { /** ImportDataRequest requestId */ requestId?: (string|null); + + /** ImportDataRequest serviceAccount */ + serviceAccount?: (string|null); } /** Represents an ImportDataRequest. */ @@ -1591,6 +1594,9 @@ export namespace google { /** ImportDataRequest requestId. */ public requestId: string; + /** ImportDataRequest serviceAccount. */ + public serviceAccount: string; + /** ImportDataRequest source. */ public source?: "sourceGcsBucket"; @@ -1689,6 +1695,9 @@ export namespace google { /** ExportDataRequest requestId */ requestId?: (string|null); + + /** ExportDataRequest serviceAccount */ + serviceAccount?: (string|null); } /** Represents an ExportDataRequest. */ @@ -1712,6 +1721,9 @@ export namespace google { /** ExportDataRequest requestId. */ public requestId: string; + /** ExportDataRequest serviceAccount. */ + public serviceAccount: string; + /** ExportDataRequest source. */ public source?: "sourceParallelstore"; diff --git a/packages/google-cloud-parallelstore/protos/protos.js b/packages/google-cloud-parallelstore/protos/protos.js index 1469a82bcbb..b5e8fd89e28 100644 --- a/packages/google-cloud-parallelstore/protos/protos.js +++ b/packages/google-cloud-parallelstore/protos/protos.js @@ -3662,6 +3662,7 @@ * @property {google.cloud.parallelstore.v1beta.IDestinationParallelstore|null} [destinationParallelstore] ImportDataRequest destinationParallelstore * @property {string|null} [name] ImportDataRequest name * @property {string|null} [requestId] ImportDataRequest requestId + * @property {string|null} [serviceAccount] ImportDataRequest serviceAccount */ /** @@ -3711,6 +3712,14 @@ */ ImportDataRequest.prototype.requestId = ""; + /** + * ImportDataRequest serviceAccount. + * @member {string} serviceAccount + * @memberof google.cloud.parallelstore.v1beta.ImportDataRequest + * @instance + */ + ImportDataRequest.prototype.serviceAccount = ""; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -3768,6 +3777,8 @@ $root.google.cloud.parallelstore.v1beta.DestinationParallelstore.encode(message.destinationParallelstore, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.requestId); + if (message.serviceAccount != null && Object.hasOwnProperty.call(message, "serviceAccount")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.serviceAccount); return writer; }; @@ -3818,6 +3829,10 @@ message.requestId = reader.string(); break; } + case 5: { + message.serviceAccount = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -3876,6 +3891,9 @@ if (message.requestId != null && message.hasOwnProperty("requestId")) if (!$util.isString(message.requestId)) return "requestId: string expected"; + if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) + if (!$util.isString(message.serviceAccount)) + return "serviceAccount: string expected"; return null; }; @@ -3905,6 +3923,8 @@ message.name = String(object.name); if (object.requestId != null) message.requestId = String(object.requestId); + if (object.serviceAccount != null) + message.serviceAccount = String(object.serviceAccount); return message; }; @@ -3924,6 +3944,7 @@ if (options.defaults) { object.name = ""; object.requestId = ""; + object.serviceAccount = ""; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -3939,6 +3960,8 @@ } if (message.requestId != null && message.hasOwnProperty("requestId")) object.requestId = message.requestId; + if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) + object.serviceAccount = message.serviceAccount; return object; }; @@ -3981,6 +4004,7 @@ * @property {google.cloud.parallelstore.v1beta.IDestinationGcsBucket|null} [destinationGcsBucket] ExportDataRequest destinationGcsBucket * @property {string|null} [name] ExportDataRequest name * @property {string|null} [requestId] ExportDataRequest requestId + * @property {string|null} [serviceAccount] ExportDataRequest serviceAccount */ /** @@ -4030,6 +4054,14 @@ */ ExportDataRequest.prototype.requestId = ""; + /** + * ExportDataRequest serviceAccount. + * @member {string} serviceAccount + * @memberof google.cloud.parallelstore.v1beta.ExportDataRequest + * @instance + */ + ExportDataRequest.prototype.serviceAccount = ""; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -4087,6 +4119,8 @@ $root.google.cloud.parallelstore.v1beta.DestinationGcsBucket.encode(message.destinationGcsBucket, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.requestId); + if (message.serviceAccount != null && Object.hasOwnProperty.call(message, "serviceAccount")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.serviceAccount); return writer; }; @@ -4137,6 +4171,10 @@ message.requestId = reader.string(); break; } + case 5: { + message.serviceAccount = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -4195,6 +4233,9 @@ if (message.requestId != null && message.hasOwnProperty("requestId")) if (!$util.isString(message.requestId)) return "requestId: string expected"; + if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) + if (!$util.isString(message.serviceAccount)) + return "serviceAccount: string expected"; return null; }; @@ -4224,6 +4265,8 @@ message.name = String(object.name); if (object.requestId != null) message.requestId = String(object.requestId); + if (object.serviceAccount != null) + message.serviceAccount = String(object.serviceAccount); return message; }; @@ -4243,6 +4286,7 @@ if (options.defaults) { object.name = ""; object.requestId = ""; + object.serviceAccount = ""; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -4258,6 +4302,8 @@ } if (message.requestId != null && message.hasOwnProperty("requestId")) object.requestId = message.requestId; + if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) + object.serviceAccount = message.serviceAccount; return object; }; diff --git a/packages/google-cloud-parallelstore/protos/protos.json b/packages/google-cloud-parallelstore/protos/protos.json index 3158349e1c5..8d58ffa556b 100644 --- a/packages/google-cloud-parallelstore/protos/protos.json +++ b/packages/google-cloud-parallelstore/protos/protos.json @@ -15,8 +15,8 @@ "java_package": "com.google.cloud.parallelstore.v1beta", "php_namespace": "Google\\Cloud\\Parallelstore\\V1beta", "ruby_package": "Google::Cloud::Parallelstore::V1beta", - "(google.api.resource_definition).type": "compute.googleapis.com/Address", - "(google.api.resource_definition).pattern": "projects/{project}/regions/{region}/addresses/{address}" + "(google.api.resource_definition).type": "iam.googleapis.com/ServiceAccount", + "(google.api.resource_definition).pattern": "projects/{project}/serviceAccounts/{service_account}" }, "nested": { "Parallelstore": { @@ -591,6 +591,14 @@ "(google.api.field_info).format": "UUID4", "(google.api.field_behavior)": "OPTIONAL" } + }, + "serviceAccount": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL", + "(google.api.resource_reference).type": "iam.googleapis.com/ServiceAccount" + } } } }, @@ -631,6 +639,14 @@ "(google.api.field_info).format": "UUID4", "(google.api.field_behavior)": "OPTIONAL" } + }, + "serviceAccount": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL", + "(google.api.resource_reference).type": "iam.googleapis.com/ServiceAccount" + } } } }, diff --git a/packages/google-cloud-parallelstore/samples/generated/v1beta/parallelstore.export_data.js b/packages/google-cloud-parallelstore/samples/generated/v1beta/parallelstore.export_data.js index 5f6235295f5..58e0f745ca5 100644 --- a/packages/google-cloud-parallelstore/samples/generated/v1beta/parallelstore.export_data.js +++ b/packages/google-cloud-parallelstore/samples/generated/v1beta/parallelstore.export_data.js @@ -54,6 +54,14 @@ function main(name) { * not supported (00000000-0000-0000-0000-000000000000). */ // const requestId = 'abc123' + /** + * Optional. User-specified Service Account (SA) credentials to be used when + * performing the transfer. + * Format: `projects/{project_id}/serviceAccounts/{service_account}` + * If unspecified, the Parallelstore service agent is used: + * service-@gcp-sa-parallelstore.iam.gserviceaccount.com) + */ + // const serviceAccount = 'abc123' // Imports the Parallelstore library const {ParallelstoreClient} = require('@google-cloud/parallelstore').v1beta; diff --git a/packages/google-cloud-parallelstore/samples/generated/v1beta/parallelstore.import_data.js b/packages/google-cloud-parallelstore/samples/generated/v1beta/parallelstore.import_data.js index 4e155295097..1a3591f45f2 100644 --- a/packages/google-cloud-parallelstore/samples/generated/v1beta/parallelstore.import_data.js +++ b/packages/google-cloud-parallelstore/samples/generated/v1beta/parallelstore.import_data.js @@ -54,6 +54,14 @@ function main(name) { * not supported (00000000-0000-0000-0000-000000000000). */ // const requestId = 'abc123' + /** + * Optional. User-specified Service Account (SA) credentials to be used when + * performing the transfer. + * Format: `projects/{project_id}/serviceAccounts/{service_account}` + * If unspecified, the Parallelstore service agent is used: + * service-@gcp-sa-parallelstore.iam.gserviceaccount.com) + */ + // const serviceAccount = 'abc123' // Imports the Parallelstore library const {ParallelstoreClient} = require('@google-cloud/parallelstore').v1beta; diff --git a/packages/google-cloud-parallelstore/samples/generated/v1beta/snippet_metadata_google.cloud.parallelstore.v1beta.json b/packages/google-cloud-parallelstore/samples/generated/v1beta/snippet_metadata_google.cloud.parallelstore.v1beta.json index f02ed662bba..31a0ad6a8d6 100644 --- a/packages/google-cloud-parallelstore/samples/generated/v1beta/snippet_metadata_google.cloud.parallelstore.v1beta.json +++ b/packages/google-cloud-parallelstore/samples/generated/v1beta/snippet_metadata_google.cloud.parallelstore.v1beta.json @@ -262,7 +262,7 @@ "segments": [ { "start": 25, - "end": 76, + "end": 84, "type": "FULL" } ], @@ -286,6 +286,10 @@ { "name": "request_id", "type": "TYPE_STRING" + }, + { + "name": "service_account", + "type": "TYPE_STRING" } ], "resultType": ".google.longrunning.Operation", @@ -314,7 +318,7 @@ "segments": [ { "start": 25, - "end": 76, + "end": 84, "type": "FULL" } ], @@ -338,6 +342,10 @@ { "name": "request_id", "type": "TYPE_STRING" + }, + { + "name": "service_account", + "type": "TYPE_STRING" } ], "resultType": ".google.longrunning.Operation", diff --git a/packages/google-cloud-parallelstore/src/v1beta/parallelstore_client.ts b/packages/google-cloud-parallelstore/src/v1beta/parallelstore_client.ts index 0f8b0574c5e..ebe08da871b 100644 --- a/packages/google-cloud-parallelstore/src/v1beta/parallelstore_client.ts +++ b/packages/google-cloud-parallelstore/src/v1beta/parallelstore_client.ts @@ -238,6 +238,9 @@ export class ParallelstoreClient { projectPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}' ), + serviceAccountPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/serviceAccounts/{service_account}' + ), }; // Some of the methods on this service return "paged" results, @@ -1110,6 +1113,12 @@ export class ParallelstoreClient { * * The request ID must be a valid UUID with the exception that zero UUID is * not supported (00000000-0000-0000-0000-000000000000). + * @param {string} [request.serviceAccount] + * Optional. User-specified Service Account (SA) credentials to be used when + * performing the transfer. + * Format: `projects/{project_id}/serviceAccounts/{service_account}` + * If unspecified, the Parallelstore service agent is used: + * service-@gcp-sa-parallelstore.iam.gserviceaccount.com) * @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. @@ -1264,6 +1273,12 @@ export class ParallelstoreClient { * * The request ID must be a valid UUID with the exception that zero UUID is * not supported (00000000-0000-0000-0000-000000000000). + * @param {string} [request.serviceAccount] + * Optional. User-specified Service Account (SA) credentials to be used when + * performing the transfer. + * Format: `projects/{project_id}/serviceAccounts/{service_account}` + * If unspecified, the Parallelstore service agent is used: + * service-@gcp-sa-parallelstore.iam.gserviceaccount.com) * @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. @@ -2059,6 +2074,46 @@ export class ParallelstoreClient { return this.pathTemplates.projectPathTemplate.match(projectName).project; } + /** + * Return a fully-qualified serviceAccount resource name string. + * + * @param {string} project + * @param {string} service_account + * @returns {string} Resource name string. + */ + serviceAccountPath(project: string, serviceAccount: string) { + return this.pathTemplates.serviceAccountPathTemplate.render({ + project: project, + service_account: serviceAccount, + }); + } + + /** + * Parse the project from ServiceAccount resource. + * + * @param {string} serviceAccountName + * A fully-qualified path representing ServiceAccount resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServiceAccountName(serviceAccountName: string) { + return this.pathTemplates.serviceAccountPathTemplate.match( + serviceAccountName + ).project; + } + + /** + * Parse the service_account from ServiceAccount resource. + * + * @param {string} serviceAccountName + * A fully-qualified path representing ServiceAccount resource. + * @returns {string} A string representing the service_account. + */ + matchServiceAccountFromServiceAccountName(serviceAccountName: string) { + return this.pathTemplates.serviceAccountPathTemplate.match( + serviceAccountName + ).service_account; + } + /** * Terminate the gRPC channel and close the client. * diff --git a/packages/google-cloud-parallelstore/test/gapic_parallelstore_v1beta.ts b/packages/google-cloud-parallelstore/test/gapic_parallelstore_v1beta.ts index ab72e4691c2..86d784d973d 100644 --- a/packages/google-cloud-parallelstore/test/gapic_parallelstore_v1beta.ts +++ b/packages/google-cloud-parallelstore/test/gapic_parallelstore_v1beta.ts @@ -2537,5 +2537,58 @@ describe('v1beta.ParallelstoreClient', () => { ); }); }); + + describe('serviceAccount', () => { + const fakePath = '/rendered/path/serviceAccount'; + const expectedParameters = { + project: 'projectValue', + service_account: 'serviceAccountValue', + }; + const client = new parallelstoreModule.v1beta.ParallelstoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.serviceAccountPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.serviceAccountPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('serviceAccountPath', () => { + const result = client.serviceAccountPath( + 'projectValue', + 'serviceAccountValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.serviceAccountPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServiceAccountName', () => { + const result = client.matchProjectFromServiceAccountName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.serviceAccountPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceAccountFromServiceAccountName', () => { + const result = + client.matchServiceAccountFromServiceAccountName(fakePath); + assert.strictEqual(result, 'serviceAccountValue'); + assert( + (client.pathTemplates.serviceAccountPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); }); });