From f058d7a475402e52f8e8d5d4f838d9423f33ffb4 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:17:07 -0800 Subject: [PATCH] feat: [netapp] Add ValidateDirectoryService API for testing AD connection of a storage pool (#5931) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Add ValidateDirectoryService API for testing AD connection of a storage pool docs: Removed the format for `replication` in message `google.cloud.netapp.v1.HybridReplicationParameters` PiperOrigin-RevId: 713157619 Source-Link: https://github.com/googleapis/googleapis/commit/7f2db36e5eb3c0ca633bd9600317c74bc26344b1 Source-Link: https://github.com/googleapis/googleapis-gen/commit/33068cc50b39cb01ecc6d175f464e138491711f2 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldGFwcC8uT3dsQm90LnlhbWwiLCJoIjoiMzMwNjhjYzUwYjM5Y2IwMWVjYzZkMTc1ZjQ2NGUxMzg0OTE3MTFmMiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot Co-authored-by: d-goog <188102366+d-goog@users.noreply.github.com> --- packages/google-cloud-netapp/README.md | 1 + .../netapp/v1/cloud_netapp_service.proto | 14 + .../google/cloud/netapp/v1/common.proto | 9 + .../google/cloud/netapp/v1/storage_pool.proto | 15 + .../google/cloud/netapp/v1/volume.proto | 4 +- .../google-cloud-netapp/protos/protos.d.ts | 130 ++++++++ packages/google-cloud-netapp/protos/protos.js | 293 ++++++++++++++++++ .../google-cloud-netapp/protos/protos.json | 46 +++ .../google-cloud-netapp/samples/README.md | 18 ++ .../v1/net_app.validate_directory_service.js | 66 ++++ ...ippet_metadata_google.cloud.netapp.v1.json | 44 +++ .../src/v1/gapic_metadata.json | 10 + .../src/v1/net_app_client.ts | 159 ++++++++++ .../src/v1/net_app_client_config.json | 4 + .../test/gapic_net_app_v1.ts | 198 ++++++++++++ 15 files changed, 1008 insertions(+), 3 deletions(-) create mode 100644 packages/google-cloud-netapp/samples/generated/v1/net_app.validate_directory_service.js diff --git a/packages/google-cloud-netapp/README.md b/packages/google-cloud-netapp/README.md index 6cfd4168531..aa3aa95e334 100644 --- a/packages/google-cloud-netapp/README.md +++ b/packages/google-cloud-netapp/README.md @@ -169,6 +169,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/ | Net_app.update_snapshot | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-netapp/samples/generated/v1/net_app.update_snapshot.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-netapp/samples/generated/v1/net_app.update_snapshot.js,packages/google-cloud-netapp/samples/README.md) | | Net_app.update_storage_pool | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-netapp/samples/generated/v1/net_app.update_storage_pool.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-netapp/samples/generated/v1/net_app.update_storage_pool.js,packages/google-cloud-netapp/samples/README.md) | | Net_app.update_volume | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-netapp/samples/generated/v1/net_app.update_volume.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-netapp/samples/generated/v1/net_app.update_volume.js,packages/google-cloud-netapp/samples/README.md) | +| Net_app.validate_directory_service | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-netapp/samples/generated/v1/net_app.validate_directory_service.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-netapp/samples/generated/v1/net_app.validate_directory_service.js,packages/google-cloud-netapp/samples/README.md) | | Net_app.verify_kms_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-netapp/samples/generated/v1/net_app.verify_kms_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-netapp/samples/generated/v1/net_app.verify_kms_config.js,packages/google-cloud-netapp/samples/README.md) | | Quickstart | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-netapp/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-netapp/samples/quickstart.js,packages/google-cloud-netapp/samples/README.md) | diff --git a/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/cloud_netapp_service.proto b/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/cloud_netapp_service.proto index d4096a9107d..9afcf3e957a 100644 --- a/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/cloud_netapp_service.proto +++ b/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/cloud_netapp_service.proto @@ -110,6 +110,20 @@ service NetApp { }; } + // ValidateDirectoryService does a connectivity check for a directory service + // policy attached to the storage pool. + rpc ValidateDirectoryService(ValidateDirectoryServiceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/storagePools/*}:validateDirectoryService" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OperationMetadata" + }; + } + // This operation will switch the active/replica zone for a regional // storagePool. rpc SwitchActiveReplicaZone(SwitchActiveReplicaZoneRequest) diff --git a/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/common.proto b/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/common.proto index 5123776afc0..0ae683c4ca8 100644 --- a/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/common.proto +++ b/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/common.proto @@ -56,6 +56,15 @@ enum EncryptionType { CLOUD_KMS = 2; } +// Type of directory service +enum DirectoryServiceType { + // Directory service type is not specified. + DIRECTORY_SERVICE_TYPE_UNSPECIFIED = 0; + + // Active directory policy attached to the storage pool. + ACTIVE_DIRECTORY = 1; +} + // Metadata for a given // [google.cloud.location.Location][google.cloud.location.Location]. message LocationMetadata { diff --git a/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/storage_pool.proto b/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/storage_pool.proto index 90d74561598..eaadbd52e3b 100644 --- a/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/storage_pool.proto +++ b/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/storage_pool.proto @@ -254,3 +254,18 @@ message StoragePool { // Optional. Specifies the active zone for regional storagePool. string zone = 21 [(google.api.field_behavior) = OPTIONAL]; } + +// ValidateDirectoryServiceRequest validates the directory service policy +// attached to the storage pool. +message ValidateDirectoryServiceRequest { + // Required. Name of the storage pool + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "netapp.googleapis.com/StoragePool" + } + ]; + + // Type of directory service policy attached to the storage pool. + DirectoryServiceType directory_service_type = 2; +} diff --git a/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/volume.proto b/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/volume.proto index a93c479ba8f..c00cffb02a0 100644 --- a/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/volume.proto +++ b/packages/google-cloud-netapp/protos/google/cloud/netapp/v1/volume.proto @@ -645,9 +645,7 @@ message TieringPolicy { // The Hybrid Replication parameters for the volume. message HybridReplicationParameters { - // Required. Desired Identifier (name) of the replication which will be created for this volume. - // Format: - // `projects/{project_id}/locations/{location}/volumes/{volume_id}/replications/{replication_id}` + // Required. Desired name for the replication of this volume. string replication = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference) = { diff --git a/packages/google-cloud-netapp/protos/protos.d.ts b/packages/google-cloud-netapp/protos/protos.d.ts index 766efb0a2b2..b3784c5afdd 100644 --- a/packages/google-cloud-netapp/protos/protos.d.ts +++ b/packages/google-cloud-netapp/protos/protos.d.ts @@ -3389,6 +3389,20 @@ export namespace google { */ public deleteStoragePool(request: google.cloud.netapp.v1.IDeleteStoragePoolRequest): Promise; + /** + * Calls ValidateDirectoryService. + * @param request ValidateDirectoryServiceRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public validateDirectoryService(request: google.cloud.netapp.v1.IValidateDirectoryServiceRequest, callback: google.cloud.netapp.v1.NetApp.ValidateDirectoryServiceCallback): void; + + /** + * Calls ValidateDirectoryService. + * @param request ValidateDirectoryServiceRequest message or plain object + * @returns Promise + */ + public validateDirectoryService(request: google.cloud.netapp.v1.IValidateDirectoryServiceRequest): Promise; + /** * Calls SwitchActiveReplicaZone. * @param request SwitchActiveReplicaZoneRequest message or plain object @@ -4113,6 +4127,13 @@ export namespace google { */ type DeleteStoragePoolCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + /** + * Callback as used by {@link google.cloud.netapp.v1.NetApp|validateDirectoryService}. + * @param error Error, if any + * @param [response] Operation + */ + type ValidateDirectoryServiceCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + /** * Callback as used by {@link google.cloud.netapp.v1.NetApp|switchActiveReplicaZone}. * @param error Error, if any @@ -10146,6 +10167,12 @@ export namespace google { CLOUD_KMS = 2 } + /** DirectoryServiceType enum. */ + enum DirectoryServiceType { + DIRECTORY_SERVICE_TYPE_UNSPECIFIED = 0, + ACTIVE_DIRECTORY = 1 + } + /** Properties of a LocationMetadata. */ interface ILocationMetadata { @@ -11987,6 +12014,109 @@ export namespace google { ERROR = 7 } } + + /** Properties of a ValidateDirectoryServiceRequest. */ + interface IValidateDirectoryServiceRequest { + + /** ValidateDirectoryServiceRequest name */ + name?: (string|null); + + /** ValidateDirectoryServiceRequest directoryServiceType */ + directoryServiceType?: (google.cloud.netapp.v1.DirectoryServiceType|keyof typeof google.cloud.netapp.v1.DirectoryServiceType|null); + } + + /** Represents a ValidateDirectoryServiceRequest. */ + class ValidateDirectoryServiceRequest implements IValidateDirectoryServiceRequest { + + /** + * Constructs a new ValidateDirectoryServiceRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.netapp.v1.IValidateDirectoryServiceRequest); + + /** ValidateDirectoryServiceRequest name. */ + public name: string; + + /** ValidateDirectoryServiceRequest directoryServiceType. */ + public directoryServiceType: (google.cloud.netapp.v1.DirectoryServiceType|keyof typeof google.cloud.netapp.v1.DirectoryServiceType); + + /** + * Creates a new ValidateDirectoryServiceRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ValidateDirectoryServiceRequest instance + */ + public static create(properties?: google.cloud.netapp.v1.IValidateDirectoryServiceRequest): google.cloud.netapp.v1.ValidateDirectoryServiceRequest; + + /** + * Encodes the specified ValidateDirectoryServiceRequest message. Does not implicitly {@link google.cloud.netapp.v1.ValidateDirectoryServiceRequest.verify|verify} messages. + * @param message ValidateDirectoryServiceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.netapp.v1.IValidateDirectoryServiceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ValidateDirectoryServiceRequest message, length delimited. Does not implicitly {@link google.cloud.netapp.v1.ValidateDirectoryServiceRequest.verify|verify} messages. + * @param message ValidateDirectoryServiceRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.netapp.v1.IValidateDirectoryServiceRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ValidateDirectoryServiceRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ValidateDirectoryServiceRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.netapp.v1.ValidateDirectoryServiceRequest; + + /** + * Decodes a ValidateDirectoryServiceRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ValidateDirectoryServiceRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.netapp.v1.ValidateDirectoryServiceRequest; + + /** + * Verifies a ValidateDirectoryServiceRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ValidateDirectoryServiceRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ValidateDirectoryServiceRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.netapp.v1.ValidateDirectoryServiceRequest; + + /** + * Creates a plain object from a ValidateDirectoryServiceRequest message. Also converts values to other types if specified. + * @param message ValidateDirectoryServiceRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.netapp.v1.ValidateDirectoryServiceRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ValidateDirectoryServiceRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ValidateDirectoryServiceRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } } } diff --git a/packages/google-cloud-netapp/protos/protos.js b/packages/google-cloud-netapp/protos/protos.js index c6191eeb135..58f89367299 100644 --- a/packages/google-cloud-netapp/protos/protos.js +++ b/packages/google-cloud-netapp/protos/protos.js @@ -8656,6 +8656,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.netapp.v1.NetApp|validateDirectoryService}. + * @memberof google.cloud.netapp.v1.NetApp + * @typedef ValidateDirectoryServiceCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ValidateDirectoryService. + * @function validateDirectoryService + * @memberof google.cloud.netapp.v1.NetApp + * @instance + * @param {google.cloud.netapp.v1.IValidateDirectoryServiceRequest} request ValidateDirectoryServiceRequest message or plain object + * @param {google.cloud.netapp.v1.NetApp.ValidateDirectoryServiceCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(NetApp.prototype.validateDirectoryService = function validateDirectoryService(request, callback) { + return this.rpcCall(validateDirectoryService, $root.google.cloud.netapp.v1.ValidateDirectoryServiceRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ValidateDirectoryService" }); + + /** + * Calls ValidateDirectoryService. + * @function validateDirectoryService + * @memberof google.cloud.netapp.v1.NetApp + * @instance + * @param {google.cloud.netapp.v1.IValidateDirectoryServiceRequest} request ValidateDirectoryServiceRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.cloud.netapp.v1.NetApp|switchActiveReplicaZone}. * @memberof google.cloud.netapp.v1.NetApp @@ -25533,6 +25566,20 @@ return values; })(); + /** + * DirectoryServiceType enum. + * @name google.cloud.netapp.v1.DirectoryServiceType + * @enum {number} + * @property {number} DIRECTORY_SERVICE_TYPE_UNSPECIFIED=0 DIRECTORY_SERVICE_TYPE_UNSPECIFIED value + * @property {number} ACTIVE_DIRECTORY=1 ACTIVE_DIRECTORY value + */ + v1.DirectoryServiceType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DIRECTORY_SERVICE_TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "ACTIVE_DIRECTORY"] = 1; + return values; + })(); + v1.LocationMetadata = (function() { /** @@ -30274,6 +30321,252 @@ return StoragePool; })(); + v1.ValidateDirectoryServiceRequest = (function() { + + /** + * Properties of a ValidateDirectoryServiceRequest. + * @memberof google.cloud.netapp.v1 + * @interface IValidateDirectoryServiceRequest + * @property {string|null} [name] ValidateDirectoryServiceRequest name + * @property {google.cloud.netapp.v1.DirectoryServiceType|null} [directoryServiceType] ValidateDirectoryServiceRequest directoryServiceType + */ + + /** + * Constructs a new ValidateDirectoryServiceRequest. + * @memberof google.cloud.netapp.v1 + * @classdesc Represents a ValidateDirectoryServiceRequest. + * @implements IValidateDirectoryServiceRequest + * @constructor + * @param {google.cloud.netapp.v1.IValidateDirectoryServiceRequest=} [properties] Properties to set + */ + function ValidateDirectoryServiceRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ValidateDirectoryServiceRequest name. + * @member {string} name + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @instance + */ + ValidateDirectoryServiceRequest.prototype.name = ""; + + /** + * ValidateDirectoryServiceRequest directoryServiceType. + * @member {google.cloud.netapp.v1.DirectoryServiceType} directoryServiceType + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @instance + */ + ValidateDirectoryServiceRequest.prototype.directoryServiceType = 0; + + /** + * Creates a new ValidateDirectoryServiceRequest instance using the specified properties. + * @function create + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @static + * @param {google.cloud.netapp.v1.IValidateDirectoryServiceRequest=} [properties] Properties to set + * @returns {google.cloud.netapp.v1.ValidateDirectoryServiceRequest} ValidateDirectoryServiceRequest instance + */ + ValidateDirectoryServiceRequest.create = function create(properties) { + return new ValidateDirectoryServiceRequest(properties); + }; + + /** + * Encodes the specified ValidateDirectoryServiceRequest message. Does not implicitly {@link google.cloud.netapp.v1.ValidateDirectoryServiceRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @static + * @param {google.cloud.netapp.v1.IValidateDirectoryServiceRequest} message ValidateDirectoryServiceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ValidateDirectoryServiceRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.directoryServiceType != null && Object.hasOwnProperty.call(message, "directoryServiceType")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.directoryServiceType); + return writer; + }; + + /** + * Encodes the specified ValidateDirectoryServiceRequest message, length delimited. Does not implicitly {@link google.cloud.netapp.v1.ValidateDirectoryServiceRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @static + * @param {google.cloud.netapp.v1.IValidateDirectoryServiceRequest} message ValidateDirectoryServiceRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ValidateDirectoryServiceRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ValidateDirectoryServiceRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.netapp.v1.ValidateDirectoryServiceRequest} ValidateDirectoryServiceRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ValidateDirectoryServiceRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.netapp.v1.ValidateDirectoryServiceRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.directoryServiceType = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ValidateDirectoryServiceRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.netapp.v1.ValidateDirectoryServiceRequest} ValidateDirectoryServiceRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ValidateDirectoryServiceRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ValidateDirectoryServiceRequest message. + * @function verify + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ValidateDirectoryServiceRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.directoryServiceType != null && message.hasOwnProperty("directoryServiceType")) + switch (message.directoryServiceType) { + default: + return "directoryServiceType: enum value expected"; + case 0: + case 1: + break; + } + return null; + }; + + /** + * Creates a ValidateDirectoryServiceRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.netapp.v1.ValidateDirectoryServiceRequest} ValidateDirectoryServiceRequest + */ + ValidateDirectoryServiceRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.netapp.v1.ValidateDirectoryServiceRequest) + return object; + var message = new $root.google.cloud.netapp.v1.ValidateDirectoryServiceRequest(); + if (object.name != null) + message.name = String(object.name); + switch (object.directoryServiceType) { + default: + if (typeof object.directoryServiceType === "number") { + message.directoryServiceType = object.directoryServiceType; + break; + } + break; + case "DIRECTORY_SERVICE_TYPE_UNSPECIFIED": + case 0: + message.directoryServiceType = 0; + break; + case "ACTIVE_DIRECTORY": + case 1: + message.directoryServiceType = 1; + break; + } + return message; + }; + + /** + * Creates a plain object from a ValidateDirectoryServiceRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @static + * @param {google.cloud.netapp.v1.ValidateDirectoryServiceRequest} message ValidateDirectoryServiceRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ValidateDirectoryServiceRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.directoryServiceType = options.enums === String ? "DIRECTORY_SERVICE_TYPE_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.directoryServiceType != null && message.hasOwnProperty("directoryServiceType")) + object.directoryServiceType = options.enums === String ? $root.google.cloud.netapp.v1.DirectoryServiceType[message.directoryServiceType] === undefined ? message.directoryServiceType : $root.google.cloud.netapp.v1.DirectoryServiceType[message.directoryServiceType] : message.directoryServiceType; + return object; + }; + + /** + * Converts this ValidateDirectoryServiceRequest to JSON. + * @function toJSON + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @instance + * @returns {Object.} JSON object + */ + ValidateDirectoryServiceRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ValidateDirectoryServiceRequest + * @function getTypeUrl + * @memberof google.cloud.netapp.v1.ValidateDirectoryServiceRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ValidateDirectoryServiceRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.netapp.v1.ValidateDirectoryServiceRequest"; + }; + + return ValidateDirectoryServiceRequest; + })(); + return v1; })(); diff --git a/packages/google-cloud-netapp/protos/protos.json b/packages/google-cloud-netapp/protos/protos.json index 68356fad6a3..7de8efc5b11 100644 --- a/packages/google-cloud-netapp/protos/protos.json +++ b/packages/google-cloud-netapp/protos/protos.json @@ -1032,6 +1032,30 @@ } ] }, + "ValidateDirectoryService": { + "requestType": "ValidateDirectoryServiceRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v1/{name=projects/*/locations/*/storagePools/*}:validateDirectoryService", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.protobuf.Empty", + "(google.longrunning.operation_info).metadata_type": "OperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{name=projects/*/locations/*/storagePools/*}:validateDirectoryService", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.protobuf.Empty", + "metadata_type": "OperationMetadata" + } + } + ] + }, "SwitchActiveReplicaZone": { "requestType": "SwitchActiveReplicaZoneRequest", "responseType": "google.longrunning.Operation", @@ -4163,6 +4187,12 @@ "CLOUD_KMS": 2 } }, + "DirectoryServiceType": { + "values": { + "DIRECTORY_SERVICE_TYPE_UNSPECIFIED": 0, + "ACTIVE_DIRECTORY": 1 + } + }, "LocationMetadata": { "fields": { "supportedServiceLevels": { @@ -4669,6 +4699,22 @@ } } } + }, + "ValidateDirectoryServiceRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "netapp.googleapis.com/StoragePool" + } + }, + "directoryServiceType": { + "type": "DirectoryServiceType", + "id": 2 + } + } } } } diff --git a/packages/google-cloud-netapp/samples/README.md b/packages/google-cloud-netapp/samples/README.md index 8c5ec974307..d0a20ec3266 100644 --- a/packages/google-cloud-netapp/samples/README.md +++ b/packages/google-cloud-netapp/samples/README.md @@ -65,6 +65,7 @@ * [Net_app.update_snapshot](#net_app.update_snapshot) * [Net_app.update_storage_pool](#net_app.update_storage_pool) * [Net_app.update_volume](#net_app.update_volume) + * [Net_app.validate_directory_service](#net_app.validate_directory_service) * [Net_app.verify_kms_config](#net_app.verify_kms_config) * [Quickstart](#quickstart) @@ -984,6 +985,23 @@ __Usage:__ +### Net_app.validate_directory_service + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-netapp/samples/generated/v1/net_app.validate_directory_service.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-netapp/samples/generated/v1/net_app.validate_directory_service.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-netapp/samples/generated/v1/net_app.validate_directory_service.js` + + +----- + + + + ### Net_app.verify_kms_config View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-netapp/samples/generated/v1/net_app.verify_kms_config.js). diff --git a/packages/google-cloud-netapp/samples/generated/v1/net_app.validate_directory_service.js b/packages/google-cloud-netapp/samples/generated/v1/net_app.validate_directory_service.js new file mode 100644 index 00000000000..41ff5e92d46 --- /dev/null +++ b/packages/google-cloud-netapp/samples/generated/v1/net_app.validate_directory_service.js @@ -0,0 +1,66 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START netapp_v1_generated_NetApp_ValidateDirectoryService_async] + /** + * 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. Name of the storage pool + */ + // const name = 'abc123' + /** + * Type of directory service policy attached to the storage pool. + */ + // const directoryServiceType = {} + + // Imports the Netapp library + const {NetAppClient} = require('@google-cloud/netapp').v1; + + // Instantiates a client + const netappClient = new NetAppClient(); + + async function callValidateDirectoryService() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await netappClient.validateDirectoryService(request); + const [response] = await operation.promise(); + console.log(response); + } + + callValidateDirectoryService(); + // [END netapp_v1_generated_NetApp_ValidateDirectoryService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-netapp/samples/generated/v1/snippet_metadata_google.cloud.netapp.v1.json b/packages/google-cloud-netapp/samples/generated/v1/snippet_metadata_google.cloud.netapp.v1.json index 5a5a1089673..2bb20e2bb99 100644 --- a/packages/google-cloud-netapp/samples/generated/v1/snippet_metadata_google.cloud.netapp.v1.json +++ b/packages/google-cloud-netapp/samples/generated/v1/snippet_metadata_google.cloud.netapp.v1.json @@ -239,6 +239,50 @@ } } }, + { + "regionTag": "netapp_v1_generated_NetApp_ValidateDirectoryService_async", + "title": "NetApp validateDirectoryService Sample", + "origin": "API_DEFINITION", + "description": " ValidateDirectoryService does a connectivity check for a directory service policy attached to the storage pool.", + "canonical": true, + "file": "net_app.validate_directory_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ValidateDirectoryService", + "fullName": "google.cloud.netapp.v1.NetApp.ValidateDirectoryService", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "directory_service_type", + "type": ".google.cloud.netapp.v1.DirectoryServiceType" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "NetAppClient", + "fullName": "google.cloud.netapp.v1.NetAppClient" + }, + "method": { + "shortName": "ValidateDirectoryService", + "fullName": "google.cloud.netapp.v1.NetApp.ValidateDirectoryService", + "service": { + "shortName": "NetApp", + "fullName": "google.cloud.netapp.v1.NetApp" + } + } + } + }, { "regionTag": "netapp_v1_generated_NetApp_SwitchActiveReplicaZone_async", "title": "NetApp switchActiveReplicaZone Sample", diff --git a/packages/google-cloud-netapp/src/v1/gapic_metadata.json b/packages/google-cloud-netapp/src/v1/gapic_metadata.json index a72f7cd45ac..890263b9885 100644 --- a/packages/google-cloud-netapp/src/v1/gapic_metadata.json +++ b/packages/google-cloud-netapp/src/v1/gapic_metadata.json @@ -75,6 +75,11 @@ "deleteStoragePool" ] }, + "ValidateDirectoryService": { + "methods": [ + "validateDirectoryService" + ] + }, "SwitchActiveReplicaZone": { "methods": [ "switchActiveReplicaZone" @@ -368,6 +373,11 @@ "deleteStoragePool" ] }, + "ValidateDirectoryService": { + "methods": [ + "validateDirectoryService" + ] + }, "SwitchActiveReplicaZone": { "methods": [ "switchActiveReplicaZone" diff --git a/packages/google-cloud-netapp/src/v1/net_app_client.ts b/packages/google-cloud-netapp/src/v1/net_app_client.ts index 193f34ac29c..2eb9a067e78 100644 --- a/packages/google-cloud-netapp/src/v1/net_app_client.ts +++ b/packages/google-cloud-netapp/src/v1/net_app_client.ts @@ -348,6 +348,12 @@ export class NetAppClient { const deleteStoragePoolMetadata = protoFilesRoot.lookup( '.google.cloud.netapp.v1.OperationMetadata' ) as gax.protobuf.Type; + const validateDirectoryServiceResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty' + ) as gax.protobuf.Type; + const validateDirectoryServiceMetadata = protoFilesRoot.lookup( + '.google.cloud.netapp.v1.OperationMetadata' + ) as gax.protobuf.Type; const switchActiveReplicaZoneResponse = protoFilesRoot.lookup( '.google.cloud.netapp.v1.StoragePool' ) as gax.protobuf.Type; @@ -557,6 +563,15 @@ export class NetAppClient { deleteStoragePoolResponse.decode.bind(deleteStoragePoolResponse), deleteStoragePoolMetadata.decode.bind(deleteStoragePoolMetadata) ), + validateDirectoryService: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + validateDirectoryServiceResponse.decode.bind( + validateDirectoryServiceResponse + ), + validateDirectoryServiceMetadata.decode.bind( + validateDirectoryServiceMetadata + ) + ), switchActiveReplicaZone: new this._gaxModule.LongrunningDescriptor( this.operationsClient, switchActiveReplicaZoneResponse.decode.bind( @@ -788,6 +803,7 @@ export class NetAppClient { 'getStoragePool', 'updateStoragePool', 'deleteStoragePool', + 'validateDirectoryService', 'switchActiveReplicaZone', 'listVolumes', 'getVolume', @@ -2219,6 +2235,149 @@ export class NetAppClient { protos.google.cloud.netapp.v1.OperationMetadata >; } + /** + * ValidateDirectoryService does a connectivity check for a directory service + * policy attached to the storage pool. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the storage pool + * @param {google.cloud.netapp.v1.DirectoryServiceType} request.directoryServiceType + * Type of directory service policy attached to the storage pool. + * @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. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.validate_directory_service.js + * region_tag:netapp_v1_generated_NetApp_ValidateDirectoryService_async + */ + validateDirectoryService( + request?: protos.google.cloud.netapp.v1.IValidateDirectoryServiceRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; + validateDirectoryService( + request: protos.google.cloud.netapp.v1.IValidateDirectoryServiceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + validateDirectoryService( + request: protos.google.cloud.netapp.v1.IValidateDirectoryServiceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + validateDirectoryService( + request?: protos.google.cloud.netapp.v1.IValidateDirectoryServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.validateDirectoryService( + request, + options, + callback + ); + } + /** + * Check the status of the long running operation returned by `validateDirectoryService()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/net_app.validate_directory_service.js + * region_tag:netapp_v1_generated_NetApp_ValidateDirectoryService_async + */ + async checkValidateDirectoryServiceProgress( + name: string + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.validateDirectoryService, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.netapp.v1.OperationMetadata + >; + } /** * This operation will switch the active/replica zone for a regional * storagePool. diff --git a/packages/google-cloud-netapp/src/v1/net_app_client_config.json b/packages/google-cloud-netapp/src/v1/net_app_client_config.json index c7bc06eaf08..bb2af8533cb 100644 --- a/packages/google-cloud-netapp/src/v1/net_app_client_config.json +++ b/packages/google-cloud-netapp/src/v1/net_app_client_config.json @@ -57,6 +57,10 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, + "ValidateDirectoryService": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "SwitchActiveReplicaZone": { "retry_codes_name": "non_idempotent", "retry_params_name": "default" diff --git a/packages/google-cloud-netapp/test/gapic_net_app_v1.ts b/packages/google-cloud-netapp/test/gapic_net_app_v1.ts index a676c24d3a6..714d3840b5e 100644 --- a/packages/google-cloud-netapp/test/gapic_net_app_v1.ts +++ b/packages/google-cloud-netapp/test/gapic_net_app_v1.ts @@ -2221,6 +2221,204 @@ describe('v1.NetAppClient', () => { }); }); + describe('validateDirectoryService', () => { + it('invokes validateDirectoryService without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ValidateDirectoryServiceRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ValidateDirectoryServiceRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.validateDirectoryService = + stubLongRunningCall(expectedResponse); + const [operation] = await client.validateDirectoryService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.validateDirectoryService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateDirectoryService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes validateDirectoryService without error using callback', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ValidateDirectoryServiceRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ValidateDirectoryServiceRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.validateDirectoryService = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.validateDirectoryService( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.netapp.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.validateDirectoryService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateDirectoryService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes validateDirectoryService with call error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ValidateDirectoryServiceRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ValidateDirectoryServiceRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.validateDirectoryService = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.validateDirectoryService(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.validateDirectoryService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateDirectoryService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes validateDirectoryService with LRO error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.netapp.v1.ValidateDirectoryServiceRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.netapp.v1.ValidateDirectoryServiceRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.validateDirectoryService = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.validateDirectoryService(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.validateDirectoryService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateDirectoryService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkValidateDirectoryServiceProgress without error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkValidateDirectoryServiceProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkValidateDirectoryServiceProgress with error', async () => { + const client = new netappModule.v1.NetAppClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkValidateDirectoryServiceProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + describe('switchActiveReplicaZone', () => { it('invokes switchActiveReplicaZone without error', async () => { const client = new netappModule.v1.NetAppClient({